summary refs log tree commit diff
path: root/pkgs/build-support/closure-info.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2023-09-28 19:25:28 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2023-10-04 18:37:00 +0200
commitc8f5c30c37e60d2c96c525d9df0917f852e7f5ad (patch)
tree37dba2fb6c94a3298fff43532f48ed7d3b322dec /pkgs/build-support/closure-info.nix
parent8bc5104a6e6a6acf09f9d7ddf1c6a9293efb405a (diff)
downloadnixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.tar
nixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.tar.gz
nixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.tar.bz2
nixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.tar.lz
nixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.tar.xz
nixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.tar.zst
nixpkgs-c8f5c30c37e60d2c96c525d9df0917f852e7f5ad.zip
pkgs/build-support: refactor drvs using `__structuredAttrs = true`
Derivations affected by this patch set `__structuredAttrs = true;` and
provide their own `builder`, i.e. it's necessary to `source .attrs.sh`.

Rather than adding even more `if`-`source` monstrums, I decided to
modify all of those derivations to use `buildCommand` or `runCommand`,
without `builder` being set.

Then, `$stdenv/setup` is sourced already and as a result it's safe to
assume that `NIX_ATTRS_JSON_FILE`/`NIX_ATTRS_SH_FILE` point to a usable
location both in a build and a shell session.
Diffstat (limited to 'pkgs/build-support/closure-info.nix')
-rw-r--r--pkgs/build-support/closure-info.nix14
1 files changed, 6 insertions, 8 deletions
diff --git a/pkgs/build-support/closure-info.nix b/pkgs/build-support/closure-info.nix
index 6b3ff6fd62b..f6c31bd786b 100644
--- a/pkgs/build-support/closure-info.nix
+++ b/pkgs/build-support/closure-info.nix
@@ -4,7 +4,7 @@
 # "nix-store --load-db" and "nix-store --register-validity
 # --hash-given".
 
-{ stdenv, buildPackages }:
+{ stdenv, coreutils, jq }:
 
 { rootPaths }:
 
@@ -19,18 +19,16 @@ stdenv.mkDerivation {
 
   preferLocalBuild = true;
 
-  PATH = "${buildPackages.coreutils}/bin:${buildPackages.jq}/bin";
+  nativeBuildInputs = [ coreutils jq ];
 
-  builder = builtins.toFile "builder"
+  buildCommand =
     ''
-      . .attrs.sh
-
       out=''${outputs[out]}
 
       mkdir $out
 
-      jq -r ".closure | map(.narSize) | add" < .attrs.json > $out/total-nar-size
-      jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < .attrs.json | head -n -1 > $out/registration
-      jq -r .closure[].path < .attrs.json > $out/store-paths
+      jq -r ".closure | map(.narSize) | add" < "$NIX_ATTRS_JSON_FILE" > $out/total-nar-size
+      jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < "$NIX_ATTRS_JSON_FILE" | head -n -1 > $out/registration
+      jq -r '.closure[].path' < "$NIX_ATTRS_JSON_FILE" > $out/store-paths
     '';
 }