Skip to content

Commit

Permalink
nixos/nix-daemon: Fix merging order for substituters option
Browse files Browse the repository at this point in the history
The `substituters` option in `nix.settings` uses the order
of the substituters listed to define priority. Prior to #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 #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.
  • Loading branch information
polykernel committed Feb 12, 2022
1 parent e8d0ffa commit 34636a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nixos/modules/services/misc/nix-daemon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] ++
Expand Down

0 comments on commit 34636a8

Please sign in to comment.