git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/etc: simplify source path handling

This change is strictly functionally equivalent because we're just lifting the transformation of `source` out of `mapAttrs` to the single point of use (in escapeShellArgs). This is also much faster because we can skip a map over all `etc` items.

commit654f41435bea857c1fa7837f4ade9f6a30d410f2 authorErik Arvstedt <erik.arvstedt@gmail.com> dateSat 25 Sep 2021, 14:32 (5 years ago) parentf05a99e
1 file changed+3−4
nixos/modules/system/etc/etc.nix+3−4
nixos/modules/system/etc/etc.nix+3−4
@@ -6,9 +6,7 @@ with lib;
66
77let
88
9− # if the source is a local file, it should be imported to the store
10− localToStore = mapAttrs (name: value: if name == "source" then "${value}" else value);
11− etc' = map localToStore (filter (f: f.enable) (attrValues config.environment.etc));
9+ etc' = filter (f: f.enable) (attrValues config.environment.etc);
1210
1311 etc = pkgs.runCommandLocal "etc" {
1412 # This is needed for the systemd module
@@ -55,7 +53,8 @@ let
5553 mkdir -p "$out/etc"
5654 ${concatMapStringsSep "\n" (etcEntry: escapeShellArgs [
5755 "makeEtcEntry"
58− etcEntry.source
56+ # Force local source paths to be added to the store
57+ "${etcEntry.source}"
5958 etcEntry.target
6059 etcEntry.mode
6160 etcEntry.user