From 34636a8525322da7945cc01c70dfb08366c5a128 Mon Sep 17 00:00:00 2001 From: polykernel <81340136+polykernel@users.noreply.github.com> Date: Sat, 12 Feb 2022 13:47:19 -0500 Subject: [PATCH] nixos/nix-daemon: Fix merging order for substituters option The `substituters` option in `nix.settings` uses the order of the substituters listed to define priority. Prior to https://github.com/NixOS/nixpkgs/pull/139075, the corresponding option `binaryCaches` is declared in the `nix` namespace, which is guaranteed to be merged last. However, the order of merging isn't guaranteed in submodules. This cause definitions to be appended to the default value instead of prepended, breaking backwards compatibility as reported in https://github.com/NixOS/nixpkgs/issues/158356. The way this is addressed in the module system is with order priorities via `mkOrder` and sorting definitions before merging. This PR restores the previous behavior by setting a higher priority to the substituters option defined internally, thus all definitions with default priority will be merged before it. This was chosen because the `mkRenamedOption` function does not preserve order priority so users using legacy options do not have precise control on placement. This change should suffice for simple configuration, but further revision to the module system is needed for to make various `mk*` functions aware of order priorities. --- nixos/modules/services/misc/nix-daemon.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index a401458c4169..ca59ea293783 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -762,7 +762,7 @@ in nix.settings = mkMerge [ { trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; - substituters = [ "https://cache.nixos.org/" ]; + substituters = mkAfter [ "https://cache.nixos.org/" ]; system-features = mkDefault ( [ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++