summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Arvstedt <erik.arvstedt@gmail.com>2021-09-25 14:32:58 +0200
committerErik Arvstedt <erik.arvstedt@gmail.com>2021-09-25 14:44:38 +0200
commit654f41435bea857c1fa7837f4ade9f6a30d410f2 (patch)
tree767d8cec22a30b833ece4425c6ab72b3a79c0d3c
parentf05a99e116df08af551c7c49e7d4aa4020d43acd (diff)
downloadnixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.tar
nixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.tar.gz
nixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.tar.bz2
nixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.tar.lz
nixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.tar.xz
nixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.tar.zst
nixpkgs-654f41435bea857c1fa7837f4ade9f6a30d410f2.zip
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.
-rw-r--r--nixos/modules/system/etc/etc.nix7
1 files changed, 3 insertions, 4 deletions
diff --git a/nixos/modules/system/etc/etc.nix b/nixos/modules/system/etc/etc.nix
index 84468ea31f7..80e728d09a6 100644
--- a/nixos/modules/system/etc/etc.nix
+++ b/nixos/modules/system/etc/etc.nix
@@ -6,9 +6,7 @@ with lib;
 
 let
 
-  # if the source is a local file, it should be imported to the store
-  localToStore = mapAttrs (name: value: if name == "source" then "${value}" else value);
-  etc' = map localToStore (filter (f: f.enable) (attrValues config.environment.etc));
+  etc' = filter (f: f.enable) (attrValues config.environment.etc);
 
   etc = pkgs.runCommandLocal "etc" {
     # This is needed for the systemd module
@@ -55,7 +53,8 @@ let
     mkdir -p "$out/etc"
     ${concatMapStringsSep "\n" (etcEntry: escapeShellArgs [
       "makeEtcEntry"
-      etcEntry.source
+      # Force local source paths to be added to the store
+      "${etcEntry.source}"
       etcEntry.target
       etcEntry.mode
       etcEntry.user