nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 76 lines 2.2 kB view raw
1{ 2 lib, 3 stdenv, 4 rustPlatform, 5 fetchFromGitHub, 6 versionCheckHook, 7 nix-update-script, 8}: 9 10rustPlatform.buildRustPackage (finalAttrs: { 11 pname = "sus-compiler"; 12 version = "0.3.7"; 13 14 src = fetchFromGitHub { 15 owner = "pc2"; 16 repo = "sus-compiler"; 17 rev = "v${finalAttrs.version}"; 18 hash = "sha256-O4aBVN7jbPm7iqMpxCRYWJ+89zcMCZTKyhRLBcQDKa8="; 19 fetchSubmodules = true; 20 leaveDotGit = true; 21 22 # Manual patch phase with replacement of Git details just before they're deleted. 23 # Also ensures reproducibility by removing build time. 24 postFetch = '' 25 cp ${./build.rs.patch} build.rs.patch 26 PATCH="$(realpath build.rs.patch)" 27 28 cd "$out" 29 30 GIT_HASH="$(git rev-parse HEAD)" 31 GIT_DATE="$(git log --pretty=format:'%ad' --date=iso-strict HEAD -1)" 32 33 substituteInPlace "$PATCH" \ 34 --replace-fail "@GIT_HASH@" "$GIT_HASH" \ 35 --replace-fail "@GIT_DATE@" "$GIT_DATE" 36 patch -p1 < "$PATCH" 37 38 find "$out" -name .git -print0 | xargs -0 rm -rf 39 ''; 40 }; 41 42 # no lockfile upstream 43 cargoLock.lockFile = ./Cargo.lock; 44 45 preBuild = '' 46 export INSTALL_SUS_HOME="$out/share/sus-compiler"; 47 mkdir -p "$INSTALL_SUS_HOME" 48 ''; 49 50 postPatch = '' 51 ln -s ${./Cargo.lock} Cargo.lock 52 ''; 53 54 # Do the install version check only on stable versions of this compiler, when the build platform 55 # is able to execute the binaries. Unstable versions report a "-devel" string instead of agreeing 56 # with the nixpkgs version scheme. 57 doInstallCheck = 58 let 59 isStable = !lib.elem "unstable" (lib.versions.splitVersion finalAttrs.version); 60 canExecute = stdenv.buildPlatform.canExecute stdenv.hostPlatform; 61 in 62 isStable && canExecute; 63 64 nativeInstallCheckInputs = [ versionCheckHook ]; 65 versionCheckProgram = "${placeholder "out"}/bin/sus_compiler"; 66 67 updateScript = nix-update-script { extraArgs = [ "--generate-lockfile" ]; }; 68 69 meta = { 70 description = "New Hardware Design Language that keeps you in the driver's seat"; 71 homepage = "https://github.com/pc2/sus-compiler"; 72 license = lib.licenses.gpl3Only; 73 maintainers = with lib.maintainers; [ pbsds ]; 74 mainProgram = "sus_compiler"; 75 }; 76})