summary refs log tree commit diff
path: root/pkgs/tools/security/grype
diff options
context:
space:
mode:
author06kellyjac <dev@j-k.io>2022-01-21 12:51:50 +0000
committer06kellyjac <dev@j-k.io>2022-01-21 12:51:50 +0000
commit454f054c5dd6f5f6ffd20cb016160d39a75a44ea (patch)
treeeb146a845d7469f4408ab24da2afff0f2ece1bb2 /pkgs/tools/security/grype
parent23e67cc7fd0d0c7d1569313a30d224bc894b443d (diff)
downloadnixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.tar
nixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.tar.gz
nixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.tar.bz2
nixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.tar.lz
nixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.tar.xz
nixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.tar.zst
nixpkgs-454f054c5dd6f5f6ffd20cb016160d39a75a44ea.zip
grype: 0.31.1 -> 0.32.0
Fill out the version info
Diffstat (limited to 'pkgs/tools/security/grype')
-rw-r--r--pkgs/tools/security/grype/default.nix31
1 files changed, 26 insertions, 5 deletions
diff --git a/pkgs/tools/security/grype/default.nix b/pkgs/tools/security/grype/default.nix
index d0f085ba924..49dc002133d 100644
--- a/pkgs/tools/security/grype/default.nix
+++ b/pkgs/tools/security/grype/default.nix
@@ -2,23 +2,44 @@
 
 buildGoModule rec {
   pname = "grype";
-  version = "0.31.1";
+  version = "0.32.0";
 
   src = fetchFromGitHub {
     owner = "anchore";
     repo = pname;
     rev = "v${version}";
-    sha256 = "sha256-3V8qBgRIogZNisUshhs9Va9cbZ5D2hBJwqXPvqSmEWw=";
+    sha256 = "sha256-jn28IusHgHHFFrvqZLIvbqCFMhMQ5K/gqC4hVQLffY0=";
+    # populate values that require us to use git. By doing this in postFetch we
+    # can delete .git afterwards and maintain better reproducibility of the src.
+    leaveDotGit = true;
+    postFetch = ''
+      cd "$out"
+      commit="$(git rev-parse HEAD)"
+      source_date_epoch=$(git log --date=format:'%Y-%m-%dT%H:%M:%SZ' -1 --pretty=%ad)
+      substituteInPlace "$out/internal/version/build.go" \
+        --replace 'gitCommit = valueNotProvided' "gitCommit = \"$commit\"" \
+        --replace 'buildDate = valueNotProvided' "buildDate = \"$source_date_epoch\""
+      find "$out" -name .git -print0 | xargs -0 rm -rf
+    '';
   };
-
-  vendorSha256 = "sha256-/Z0tRzd7v84h8TSfbT4EqwyHWpAb30VNr4EDrNlHyd4=";
+  vendorSha256 = "sha256-05/xFjgiqbXy7Y2LTGHcXtvusGgfZ/TwLQHaO8rIjvc=";
 
   nativeBuildInputs = [ installShellFiles ];
 
   ldflags = [
-    "-s" "-w" "-X github.com/anchore/grype/internal/version.version=${version}"
+    "-s"
+    "-w"
+    "-X github.com/anchore/grype/internal/version.version=${version}"
+    "-X github.com/anchore/grype/internal/version.gitTreeState=clean"
   ];
 
+  preBuild = ''
+    # grype version also displays the version of the syft library used
+    # we need to grab it from the go.sum and add an ldflag for it
+    SYFTVERSION="$(grep "github.com/anchore/syft" go.sum -m 1 | awk '{print $2}')"
+    ldflags+=" -X github.com/anchore/grype/internal/version.syftVersion=$SYFTVERSION"
+  '';
+
   # Tests require a running Docker instance
   doCheck = false;