diff options
| author | Emily <vcs@emily.moe> | 2023-07-16 12:13:27 +0100 |
|---|---|---|
| committer | Emily <vcs@emily.moe> | 2023-07-16 12:13:27 +0100 |
| commit | c91c3519435a267dc7bcfa78bbd6ba158435f7f4 (patch) | |
| tree | 5544213e4b61ad4bc45dafb7df4d7d2a8842f69d /modules/system | |
| parent | 63af129cb56548edf8e620437443f8e8b57864f9 (diff) | |
etc: rename activation script variables
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/etc.nix | 52 |
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 "[1;31merror: not linking environment.etc.\"''${l#/etc/}\" because $l already exists, skipping...[0m" >&2 - echo "[1;31mexisting file has unknown content $o, move and activate again to apply[0m" >&2 + if [ -z "$knownSha256Hash" ]; then + echo "[1;31merror: not linking environment.etc.\"''${etcFile#/etc/}\" because $etcFile already exists, skipping...[0m" >&2 + echo "[1;31mexisting file has unknown content $etcFileSha256, move and activate again to apply[0m" >&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 ''; |
