1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

nix: make sure extra- settings are applied last

All extra- settings should come after their unprefixed counterpart, because
the entries of the config file are processed from top to bottom and appending
should happen after overwriting.

This is a port of https://github.com/NixOS/nixpkgs/pull/278064 .
This commit is contained in:
Alois Wohlschlager 2024-11-10 11:55:47 +01:00
parent c7c2517612
commit e769196105
No known key found for this signature in database
GPG key ID: E0F59EA5E5216914
2 changed files with 13 additions and 5 deletions

View file

@ -3,10 +3,11 @@
let
inherit (lib)
boolToString concatStringsSep escape floatToString getVersion isBool
isConvertibleWithToString isDerivation isFloat isInt isList isString
literalExpression maintainers mapAttrsToList mkDefault mkEnableOption mkIf
mkMerge mkOption optionalString toPretty types versionAtLeast;
boolToString concatStringsSep escape filterAttrs floatToString getVersion
hasPrefix isBool isConvertibleWithToString isDerivation isFloat isInt isList
isString literalExpression maintainers mapAttrsToList mkDefault
mkEnableOption mkIf mkMerge mkOption optionalString toPretty types
versionAtLeast;
cfg = config.nix;
@ -65,13 +66,19 @@ let
mkKeyValuePairs = attrs:
concatStringsSep "\n" (mapAttrsToList mkKeyValue attrs);
isExtra = key: hasPrefix "extra-" key;
in pkgs.writeTextFile {
name = "nix.conf";
# workaround for https://github.com/NixOS/nix/issues/9487
# extra-* settings must come after their non-extra counterpart
text = ''
# WARNING: this file is generated from the nix.settings option in
# your Home Manager configuration at $XDG_CONFIG_HOME/nix/nix.conf.
# Do not edit it!
${mkKeyValuePairs cfg.settings}
${mkKeyValuePairs
(filterAttrs (key: value: !(isExtra key)) cfg.settings)}
${mkKeyValuePairs (filterAttrs (key: value: isExtra key) cfg.settings)}
${cfg.extraOptions}
'';
checkPhase =

View file

@ -5,3 +5,4 @@ show-trace = true
system-features = big-parallel kvm recursive-nix
use-sandbox = true