summary refs log tree commit diff
path: root/pkgs/build-support/binary-cache
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/binary-cache
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/binary-cache')
-rw-r--r--pkgs/build-support/binary-cache/default.nix13
-rw-r--r--pkgs/build-support/binary-cache/make-binary-cache.py2
2 files changed, 5 insertions, 10 deletions
diff --git a/pkgs/build-support/binary-cache/default.nix b/pkgs/build-support/binary-cache/default.nix
index 27f9ad96289..8c610c51227 100644
--- a/pkgs/build-support/binary-cache/default.nix
+++ b/pkgs/build-support/binary-cache/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, buildPackages }:
+{ lib, stdenv, coreutils, jq, python3, nix, xz }:
 
 # This function is for creating a flat-file binary cache, i.e. the kind created by
 # nix copy --to file:///some/path and usable as a substituter (with the file:// prefix).
@@ -19,15 +19,10 @@ stdenv.mkDerivation {
 
   preferLocalBuild = true;
 
-  PATH = lib.makeBinPath (with buildPackages; [ coreutils jq python3 nix xz ]);
+  nativeBuildInputs = [ coreutils jq python3 nix xz ];
 
-  builder = builtins.toFile "builder" ''
-    . .attrs.sh
-
-    export out=''${outputs[out]}
-
-    mkdir $out
-    mkdir $out/nar
+  buildCommand = ''
+    mkdir -p $out/nar
 
     python ${./make-binary-cache.py}
 
diff --git a/pkgs/build-support/binary-cache/make-binary-cache.py b/pkgs/build-support/binary-cache/make-binary-cache.py
index 16dd8a7e96b..589d005562b 100644
--- a/pkgs/build-support/binary-cache/make-binary-cache.py
+++ b/pkgs/build-support/binary-cache/make-binary-cache.py
@@ -3,7 +3,7 @@ import json
 import os
 import subprocess
 
-with open(".attrs.json", "r") as f:
+with open(os.environ["NIX_ATTRS_JSON_FILE"], "r") as f:
   closures = json.load(f)["closure"]
 
 os.chdir(os.environ["out"])