Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchbzr, 5 fetchFromGitHub, 6 libsForQt5, 7 versionNum ? "1.1.0", 8}: 9 10let 11 versionInfo = { 12 "0.4.15" = rec { 13 release = "SR10"; 14 rev = "291"; 15 src = fetchbzr { 16 # the branch name does not mach the version for some reason 17 url = "https://code.launchpad.net/~arcachofo/simulide/simulide_0.4.14"; 18 sha256 = "sha256-BBoZr/S2pif0Jft5wrem8y00dXl08jq3kFiIUtOr3LM="; 19 inherit rev; 20 }; 21 }; 22 "1.0.0" = rec { 23 release = "SR2"; 24 rev = "1449"; 25 src = fetchbzr { 26 url = "https://code.launchpad.net/~arcachofo/simulide/1.0.0"; 27 sha256 = "sha256-rJWZvnjVzaKXU2ktbde1w8LSNvu0jWkDIk4dq2l7t5g="; 28 inherit rev; 29 }; 30 }; 31 "1.1.0" = rec { 32 release = "SR1"; 33 rev = "2005"; 34 src = fetchbzr { 35 url = "https://code.launchpad.net/~arcachofo/simulide/1.1.0"; 36 sha256 = "sha256-YVQduUjPQF5KxMlm730FZTShHP/7JEcAMIFn+mQITrQ="; 37 inherit rev; 38 }; 39 }; 40 "1.2.0" = rec { 41 release = "RC1"; 42 rev = "da3a925491fab9fa2a8633d18e45f8e1b576c9d2"; 43 src = fetchFromGitHub { 44 owner = "eeTools"; 45 repo = "SimulIDE-dev"; 46 hash = "sha256-6Gh0efBizDK1rUNkyU+/ysj7QwkAs3kTA1mQZYFb/pI="; 47 inherit rev; 48 }; 49 }; 50 }; 51in 52 53let 54 inherit (versionInfo.${versionNum} or (throw "Unsupported versionNum")) release rev src; 55 56 iconPath = 57 if lib.versionOlder versionNum "1.0.0" then 58 "resources/icons/hicolor/256x256/simulide.png" # upstream had a messed up icon path in this release 59 else 60 "resources/icons/simulide.png"; 61 62 release' = lib.optionalString (lib.versionOlder versionNum "1.2.0") "-" + release; 63in 64 65stdenv.mkDerivation { 66 pname = "simulide"; 67 version = "${versionNum}-${release}"; 68 inherit src; 69 70 patches = lib.optionals (versionNum == "1.0.0") [ 71 # a static field was declared as protected but was accessed 72 # from a place where it would have had to be public 73 # this is only an error when using clang, gcc is more lenient 74 ./clang-fix-protected-field.patch 75 ]; 76 77 postPatch = '' 78 sed -i resources/simulide.desktop \ 79 -e "s|^Exec=.*$|Exec=simulide|" \ 80 -e "s|^Icon=.*$|Icon=simulide|" 81 82 # Note: older versions don't have REV_NO 83 # Note: the project file hardcodes a homebrew gcc compiler when using darwin 84 # which we don't want, so we just delete the relevant lines 85 sed -i SimulIDE.pr* \ 86 -e "s|^VERSION = .*$|VERSION = ${versionNum}|" \ 87 -e "s|^RELEASE = .*$|RELEASE = ${release'}|" \ 88 -e "s|^REV_NO = .*$|REV_NO = ${rev}|" \ 89 -e "s|^BUILD_DATE = .*$|BUILD_DATE = ??????|" \ 90 -e "/QMAKE_CC/d" \ 91 -e "/QMAKE_CXX/d" \ 92 -e "/QMAKE_LINK/d" 93 94 ${lib.optionalString (lib.versionOlder versionNum "1.0.0") '' 95 # GCC 13 needs the <cstdint> header explicitly included 96 sed -i src/gpsim/value.h -e '1i #include <cstdint>' 97 sed -i src/gpsim/modules/watchdog.h -e '1i #include <cstdint>' 98 ''} 99 ''; 100 101 preConfigure = '' 102 cd build_XX 103 ''; 104 105 nativeBuildInputs = [ 106 libsForQt5.qmake 107 libsForQt5.wrapQtAppsHook 108 ]; 109 110 buildInputs = [ 111 libsForQt5.qtserialport 112 libsForQt5.qtmultimedia 113 libsForQt5.qttools 114 ] 115 ++ lib.optionals (lib.versionOlder versionNum "1.1.0") [ 116 libsForQt5.qtscript 117 ]; 118 119 installPhase = '' 120 runHook preInstall 121 122 ${lib.optionalString stdenv.hostPlatform.isLinux '' 123 install -Dm644 ../resources/simulide.desktop $out/share/applications/simulide.desktop 124 install -Dm644 ../${iconPath} $out/share/icons/hicolor/256x256/apps/simulide.png 125 ''} 126 127 pushd executables/SimulIDE_* 128 ${ 129 if stdenv.hostPlatform.isDarwin then 130 '' 131 mkdir -p $out/Applications 132 cp -r simulide.app $out/Applications 133 '' 134 else if lib.versionOlder versionNum "1.0.0" then 135 '' 136 mkdir -p $out/share/simulide $out/bin 137 cp -r share/simulide/* $out/share/simulide 138 cp bin/simulide $out/bin/simulide 139 '' 140 else 141 '' 142 mkdir -p $out/share/simulide $out/bin 143 cp -r data examples $out/share/simulide 144 cp simulide $out/bin/simulide 145 '' 146 } 147 popd 148 149 runHook postInstall 150 ''; 151 152 # on darwin there are some binaries in the examples directory which 153 # accidentally get wrapped by wrapQtAppsHook so we do the wrapping manually instead 154 dontWrapQtApps = stdenv.hostPlatform.isDarwin; 155 156 postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' 157 mkdir -p $out/bin 158 wrapQtApp $out/Applications/simulide.app/Contents/MacOs/simulide 159 ln -s $out/Applications/simulide.app/Contents/MacOs/simulide $out/bin/simulide 160 ''; 161 162 meta = { 163 description = "Simple real time electronic circuit simulator"; 164 longDescription = '' 165 SimulIDE is a simple real time electronic circuit simulator, intended for hobbyist or students 166 to learn and experiment with analog and digital electronic circuits and microcontrollers. 167 It supports PIC, AVR, Arduino and other MCUs and MPUs. 168 ''; 169 homepage = "https://simulide.com/"; 170 license = lib.licenses.gpl3Only; 171 mainProgram = "simulide"; 172 maintainers = with lib.maintainers; [ 173 carloscraveiro 174 tomasajt 175 ]; 176 platforms = [ 177 "x86_64-linux" 178 "x86_64-darwin" 179 ]; 180 }; 181}