From 07942cdbdf40df390eb29ddf3f8f0264deb9623e Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 12 Feb 2023 07:55:59 -0800 Subject: [PATCH] setup-hooks/reproducible-builds.sh: NIX_OUTPATH_USED_AS_RANDOM_SEED For reproducibility, nixpkgs sets `-frandom-seed` to the first 10 characters of the outpath of the derivation being built. This PR allows to manually select from which outpath the 10-character prefix is taken, by setting `NIX_OUTPATH_USED_AS_RANDOM_SEED` as a derivation attribute (or directly as an environment variable). For an example use of this functionality, see: https://github.com/NixOS/nixpkgs/pull/209870 --- pkgs/build-support/setup-hooks/reproducible-builds.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/setup-hooks/reproducible-builds.sh b/pkgs/build-support/setup-hooks/reproducible-builds.sh index 7b52f84df67b4..5e27ce8a25fec 100644 --- a/pkgs/build-support/setup-hooks/reproducible-builds.sh +++ b/pkgs/build-support/setup-hooks/reproducible-builds.sh @@ -3,7 +3,8 @@ # derivation and not easily collide with other builds. # We also truncate the hash so that it cannot cause reference cycles. NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE:-} -frandom-seed=$( - outbase="${out##*/}" + randSeed=${NIX_OUTPATH_USED_AS_RANDOM_SEED:-$out} + outbase="${randSeed##*/}" randomseed="${outbase:0:10}" echo $randomseed )"