about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/setup-hooks/reproducible-builds.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/setup-hooks/reproducible-builds.sh')
-rw-r--r--nixpkgs/pkgs/build-support/setup-hooks/reproducible-builds.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/build-support/setup-hooks/reproducible-builds.sh b/nixpkgs/pkgs/build-support/setup-hooks/reproducible-builds.sh
new file mode 100644
index 000000000000..5e27ce8a25fe
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/setup-hooks/reproducible-builds.sh
@@ -0,0 +1,11 @@
+# Use the last part of the out path as hash input for the build.
+# This should ensure that it is deterministic across rebuilds of the same
+# 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=$(
+    randSeed=${NIX_OUTPATH_USED_AS_RANDOM_SEED:-$out}
+    outbase="${randSeed##*/}"
+    randomseed="${outbase:0:10}"
+    echo $randomseed
+)"
+export NIX_CFLAGS_COMPILE