summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/etc.nix52
1 files changed, 26 insertions, 26 deletions
diff --git a/modules/system/etc.nix b/modules/system/etc.nix
index 2dfafcc..05cc5de 100644
--- a/modules/system/etc.nix
+++ b/modules/system/etc.nix
@@ -52,40 +52,40 @@ in
ln -sfn "$(readlink -f $systemConfig/etc)" /etc/static
errorOccurred=false
- for f in $(find /etc/static/* -type l); do
- l=/etc/''${f#/etc/static/}
- d=''${l%/*}
- if [ ! -e "$d" ]; then
- mkdir -p "$d"
+ for etcStaticFile in $(find /etc/static/* -type l); do
+ etcFile=/etc/''${etcStaticFile#/etc/static/}
+ etcDir=''${etcFile%/*}
+ if [ ! -e "$etcDir" ]; then
+ mkdir -p "$etcDir"
fi
- if [ -e "$f".copy ]; then
- cp "$f" "$l"
+ if [ -e "$etcStaticFile".copy ]; then
+ cp "$etcStaticFile" "$etcFile"
continue
fi
- if [ -e "$l" ]; then
- if [ "$(readlink "$l")" != "$f" ]; then
- if ! grep -q /etc/static "$l"; then
- o=''$(shasum -a256 "$l")
- o=''${o%% *}
- for h in ''${etcSha256Hashes["$l"]}; do
- if [ "$o" = "$h" ]; then
- mv "$l" "$l.before-nix-darwin"
- ln -s "$f" "$l"
+ if [ -e "$etcFile" ]; then
+ if [ "$(readlink "$etcFile")" != "$etcStaticFile" ]; then
+ if ! grep -q /etc/static "$etcFile"; then
+ etcFileSha256=''$(shasum -a256 "$etcFile")
+ etcFileSha256=''${etcFileSha256%% *}
+ for knownSha256Hash in ''${etcSha256Hashes["$etcFile"]}; do
+ if [ "$etcFileSha256" = "$knownSha256Hash" ]; then
+ mv "$etcFile" "$etcFile.before-nix-darwin"
+ ln -s "$etcStaticFile" "$etcFile"
break
else
- h=
+ knownSha256Hash=
fi
done
- if [ -z "$h" ]; then
- echo "error: not linking environment.etc.\"''${l#/etc/}\" because $l already exists, skipping..." >&2
- echo "existing file has unknown content $o, move and activate again to apply" >&2
+ if [ -z "$knownSha256Hash" ]; then
+ echo "error: not linking environment.etc.\"''${etcFile#/etc/}\" because $etcFile already exists, skipping..." >&2
+ echo "existing file has unknown content $etcFileSha256, move and activate again to apply" >&2
errorOccurred=true
fi
fi
fi
else
- ln -s "$f" "$l"
+ ln -s "$etcStaticFile" "$etcFile"
fi
done
@@ -93,11 +93,11 @@ in
exit 1
fi
- for l in $(find /etc/* -type l 2> /dev/null); do
- f="$(echo $l | sed 's,/etc/,/etc/static/,')"
- f=/etc/static/''${l#/etc/}
- if [ "$(readlink "$l")" = "$f" -a ! -e "$(readlink -f "$l")" ]; then
- rm "$l"
+ for etcFile in $(find /etc/* -type l 2> /dev/null); do
+ etcStaticFile="$(echo $etcFile | sed 's,/etc/,/etc/static/,')"
+ etcStaticFile=/etc/static/''${etcFile#/etc/}
+ if [ "$(readlink "$etcFile")" = "$etcStaticFile" -a ! -e "$(readlink -f "$etcFile")" ]; then
+ rm "$etcFile"
fi
done
'';