From 859c1e74ef5a5ab4161249b15dc4eb0618df2f7c Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 14 May 2024 21:19:49 +0000 Subject: [PATCH] Enable always-allow-substitutes by default A typical CI machine will have fast internet access, but may not have all the inputs already in the store to rebuild trivial derivations marked with `allowSubstitutes = false`. This leads to expensive cycles of downloads and rebuilds for derivations like the top-level NixOS system, which will be rebuilt from scratch on every CI run, despite being cached. --- install-nix.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install-nix.sh b/install-nix.sh index 83c4354..911a358 100755 --- a/install-nix.sh +++ b/install-nix.sh @@ -56,6 +56,11 @@ fi if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "experimental-features" ]]; then add_config "experimental-features = nix-command flakes" fi +# Always allow substituting from the cache, even if the derivation has `allowSubstitutes = false`. +# This is a CI optimisation to avoid having to download the inputs for already-cached derivations to rebuild trivial text files. +if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "always-allow-substitutes" ]]; then + add_config "always-allow-substitutes = true" +fi # Nix installer flags installer_options=(