From 2b819c98f75513ef88848f054d8e79a4f08386b0 Mon Sep 17 00:00:00 2001 From: Stevan Andjelkovic Date: Mon, 12 Apr 2021 10:33:52 +0200 Subject: [PATCH] nix(cli, db, debugger, ltl): move stamping version out of buildPhase --- default.nix | 12 ++++++++++-- src/cli/default.nix | 4 +++- src/db/default.nix | 4 +++- src/debugger/default.nix | 4 +++- src/ltl/default.nix | 7 ++++--- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/default.nix b/default.nix index 8b567f96..16455e20 100644 --- a/default.nix +++ b/default.nix @@ -139,7 +139,7 @@ stdenv.mkDerivation { | hexdump -ve '1/1 "%.2X"')" export REAL_VERSION="$(echo -n ${pkgs.lib.commitIdFromGitRepo ./.git + "-nix"} \ | hexdump -ve '1/1 "%.2X"')" - for component in ldfi checker scheduler; do + for component in checker db debug ldfi ltl scheduler; do # TODO(stevan): only do the next steps if --version returns the dummy version? hexdump -ve '1/1 "%.2X"' $out/bin/detsys-$component \ | sed "s/$DUMMY_VERSION/$REAL_VERSION/" \ @@ -147,5 +147,13 @@ stdenv.mkDerivation { mv $out/bin/detsys-$component-patched $out/bin/detsys-$component chmod 755 $out/bin/detsys-$component done - ''; + + # The cli binary doesn't follow the same naming convention as the other + # components, so we treat it separately. + hexdump -ve '1/1 "%.2X"' $out/bin/detsys \ + | sed "s/$DUMMY_VERSION/$REAL_VERSION/" \ + | xxd -r -p > $out/bin/detsys-patched + mv $out/bin/detsys-patched $out/bin/detsys + chmod 755 $out/bin/detsys + ''; } diff --git a/src/cli/default.nix b/src/cli/default.nix index 3fd81cb6..db9b6892 100644 --- a/src/cli/default.nix +++ b/src/cli/default.nix @@ -20,7 +20,9 @@ buildGoModule rec { vendorSha256 = "1b99x48mqbayfa4zsqq1nkbamqw6r1x46qcsnkn40bvddm99l5jx"; buildFlagsArray = - [ "-ldflags=-X main.version=${lib.commitIdFromGitRepo ./../../.git}-nix" ]; + # This is a dummy git hash to avoid breaking the nix cache, it will be + # patched in the `postInstall` phase of the top-level `default.nix`. + [ "-ldflags=-X main.version=0000000000000000000000000000000000000000-nix" ]; preBuild = '' # We need to put the source of the library in `../lib`, because diff --git a/src/db/default.nix b/src/db/default.nix index fe7d94ae..178f1843 100644 --- a/src/db/default.nix +++ b/src/db/default.nix @@ -20,7 +20,9 @@ buildGoModule rec { vendorSha256 = "027028sx9dz7ixz31611xcbrv9z2h62rmiyl74fa405k5m1yaljc"; buildFlagsArray = - [ "-ldflags=-X main.version=${lib.commitIdFromGitRepo ./../../.git + "-nix"}" ]; + # This is a dummy git hash to avoid breaking the nix cache, it will be + # patched in the `postInstall` phase of the top-level `default.nix`. + [ "-ldflags=-X main.version=0000000000000000000000000000000000000000-nix" ]; preBuild = '' # We need to put the source of the library in `../lib`, because diff --git a/src/debugger/default.nix b/src/debugger/default.nix index 1eac75f2..bad9072e 100644 --- a/src/debugger/default.nix +++ b/src/debugger/default.nix @@ -19,7 +19,9 @@ buildGoModule rec { vendorSha256 = "1y6yq31zmhv1278wf2lpf9p90nlvj44iqcrka9fq8pihdqq3pv7n"; buildFlagsArray = - [ "-ldflags=-X main.version=${lib.commitIdFromGitRepo ./../../.git + "-nix"}" ]; + # This is a dummy git hash to avoid breaking the nix cache, it will be + # patched in the `postInstall` phase of the top-level `default.nix`. + [ "-ldflags=-X main.version=0000000000000000000000000000000000000000-nix" ]; subPackages = [ "cmd/detsys-debug" ]; diff --git a/src/ltl/default.nix b/src/ltl/default.nix index 989c5735..541be4fa 100644 --- a/src/ltl/default.nix +++ b/src/ltl/default.nix @@ -13,9 +13,10 @@ in pkg.overrideAttrs (attrs: { pname = "detsys-ltl"; src = gitignoreSource ./.; - configureFlags = [ - "--ghc-option=-D__GIT_HASH__=\"${nixpkgs.lib.commitIdFromGitRepo ./../../.git + "-nix"}\"" - ]; + configureFlags = + # This is a dummy git hash to avoid breaking the nix cache, it will be + # patched in the `postInstall` phase of the top-level `default.nix`. + [ "--ghc-option=-D__GIT_HASH__=\"0000000000000000000000000000000000000000-nix\"" ]; # this should probably check that attrs.checkInputs doesn't exist checkInputs = [ nixpkgs.pkgs.haskell.packages.${compiler}.tasty-discover ]; })