diff options
author | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-05-31 14:44:15 +0200 |
---|---|---|
committer | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-05-31 14:49:39 +0200 |
commit | 8cd17b40df9c1ebbd23e75f607646ee628ab35bf (patch) | |
tree | 774274993e1c6ebefd28a38075fae7b1586b220b | |
parent | 96a346254d6c39d45f816e9c5f903a2efa3d1c0d (diff) |
build(nix): make package version more accurate
Would still be better to have commit rev included if
applicable/available but still better than before.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
-rw-r--r-- | flake.nix | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -57,21 +57,29 @@ ... }: let + inherit (builtins) readFile split; + inherit (lib.lists) findFirst; + inherit (lib.strings) hasPrefix removePrefix substring; + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml); craneLib = crane.mkLib pkgs; - commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision); + libbcachefsCommit = substring 0 7 (builtins.readFile ./.bcachefs_revision); + makefileVersion = removePrefix "VERSION=" ( + findFirst (line: hasPrefix "VERSION=" line) "VERSION=0.0.0" (split "\n" (readFile ./Makefile)) + ); + version = "${makefileVersion}+git-${libbcachefsCommit}"; commonArgs = { - version = "git-${commit}"; + inherit version; src = self; makeFlags = [ "DESTDIR=${placeholder "out"}" "PREFIX=" - "VERSION=${commit}" + "VERSION=${version}" ]; dontStrip = true; @@ -116,7 +124,7 @@ installCheckPhase = '' runHook preInstallCheck - test "$($out/bin/bcachefs version)" = "${commit}" + test "$($out/bin/bcachefs version)" = "${version}" runHook postInstallCheck ''; |