summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-01-02 20:09:54 +0100
committerDaiderd Jordan <daiderd@gmail.com>2017-01-02 20:09:54 +0100
commite8472833118270918c9c4e7bdb4e44060e2e44d4 (patch)
treef71f8e704bb576d6ec3adc9d9500fca349a45556 /modules/system
parent6305c0675ff4c0cc963c25228e631f1a2a685d69 (diff)
environment.etc: improve activation
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/etc.nix24
1 files changed, 14 insertions, 10 deletions
diff --git a/modules/system/etc.nix b/modules/system/etc.nix
index 4b92dc0..92a84d0 100644
--- a/modules/system/etc.nix
+++ b/modules/system/etc.nix
@@ -44,21 +44,25 @@ in
ln -sfn "$(readlink -f $systemConfig/etc)" /etc/static
- for link in $(ls /etc/static/); do
- if [ -e "/etc/$link" ]; then
- if [ ! -L "/etc/$link" ]; then
- echo "warning: not linking /etc/static/$link because /etc/$link exists, skipping..." >&2
+ for f in $(find /etc/static/* -type l); do
+ l="$(echo $f | sed 's,/etc/static/,/etc/,')"
+ d="$(dirname $l)"
+ if [ ! -e "$d" ]; then
+ mkdir -p "$d"
+ fi
+ if [ -e "$l" ]; then
+ if [ "$(readlink $l)" != "$f" ]; then
+ echo "warning: not linking $l because $l exists, skipping..." >&2
fi
else
- ln -sfn "/etc/static/$link" "/etc/$link"
+ ln -s "$f" "$l"
fi
done
- for link in $(find /etc/ -maxdepth 1 -type l); do
- if [[ "$(readlink $link)" == /etc/static/* ]]; then
- if [ ! -e "$(readlink -f $link)" ]; then
- rm $link
- fi
+ for l in $(find /etc/* -type l 2> /dev/null); do
+ f="$(echo $l | sed 's,/etc/,/etc/static/,')"
+ if [ "$(readlink $l)" = "$f" -a ! -e "$(readlink -f $l)" ]; then
+ rm "$l"
fi
done
'';