summaryrefslogtreecommitdiff
path: root/modules/system/etc.nix
diff options
context:
space:
mode:
authorEmily <vcs@emily.moe>2023-07-16 17:02:10 +0100
committerEmily <vcs@emily.moe>2024-06-15 12:15:13 +0100
commit36a15e8c6c4686be29ccbf0ae0ac1d6133074615 (patch)
tree794941cdc402380430cd698af2f7abfcec7e1339 /modules/system/etc.nix
parentb833d4a32d965e6393a63b2c91b46eca2a5030d8 (diff)
write-text: remove support for `copy`
This is a huge anti‐declarative footgun; `copy` files cannot distinguish if a previous version is managed by nix-darwin, so they can’t check the hash, so they’re prone to destroying data, and copied files are not deleted when they’re removed from the system configuration, which led to a security bug. Nothing else in‐tree was using this functionality, so let’s make sure it doesn’t cause any more bugs.
Diffstat (limited to 'modules/system/etc.nix')
-rw-r--r--modules/system/etc.nix19
1 files changed, 5 insertions, 14 deletions
diff --git a/modules/system/etc.nix b/modules/system/etc.nix
index 008fb1c..bc60bef 100644
--- a/modules/system/etc.nix
+++ b/modules/system/etc.nix
@@ -10,7 +10,6 @@ let
};
etc = filter (f: f.enable) (attrValues config.environment.etc);
- etcCopy = filter (f: f.copy) (attrValues config.environment.etc);
in
@@ -34,9 +33,10 @@ in
''
mkdir -p $out/etc
cd $out/etc
- ${concatMapStringsSep "\n" (attr: "mkdir -p $(dirname '${attr.target}')") etc}
- ${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") etc}
- ${concatMapStringsSep "\n" (attr: "touch '${attr.target}'.copy") etcCopy}
+ ${concatMapStringsSep "\n" (attr: ''
+ mkdir -p "$(dirname ${escapeShellArg attr.target})"
+ ln -s ${escapeShellArgs [ attr.source attr.target ]}
+ '') etc}
'';
system.activationScripts.etcChecks.text = ''
@@ -55,10 +55,6 @@ in
etcStaticFile=/etc/static/$subPath
etcFile=/etc/$subPath
- if [[ -e $configFile.copy ]]; then
- continue
- fi
-
# We need to check files that exist and aren't already links to
# $etcStaticFile for known hashes.
if [[
@@ -109,11 +105,6 @@ in
mkdir -p "$etcDir"
fi
- if [[ -e $etcStaticFile.copy ]]; then
- cp "$etcStaticFile" "$etcFile"
- continue
- fi
-
if [[ -e $etcFile ]]; then
if [[ $(readlink -- "$etcFile") == "$etcStaticFile" ]]; then
continue
@@ -130,7 +121,7 @@ in
# Delete stale links into /etc/static.
if [[
- $(readlink "$etcFile") == "$etcStaticFile"
+ $(readlink -- "$etcFile") == "$etcStaticFile"
&& ! -e $etcStaticFile
]]; then
rm "$etcFile"