mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-16 05:18:17 +00:00
environment.etc: improve activation
This commit is contained in:
parent
6305c0675f
commit
e847283311
1 changed files with 14 additions and 10 deletions
|
@ -44,21 +44,25 @@ in
|
||||||
|
|
||||||
ln -sfn "$(readlink -f $systemConfig/etc)" /etc/static
|
ln -sfn "$(readlink -f $systemConfig/etc)" /etc/static
|
||||||
|
|
||||||
for link in $(ls /etc/static/); do
|
for f in $(find /etc/static/* -type l); do
|
||||||
if [ -e "/etc/$link" ]; then
|
l="$(echo $f | sed 's,/etc/static/,/etc/,')"
|
||||||
if [ ! -L "/etc/$link" ]; then
|
d="$(dirname $l)"
|
||||||
echo "warning: not linking /etc/static/$link because /etc/$link exists, skipping..." >&2
|
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
|
fi
|
||||||
else
|
else
|
||||||
ln -sfn "/etc/static/$link" "/etc/$link"
|
ln -s "$f" "$l"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for link in $(find /etc/ -maxdepth 1 -type l); do
|
for l in $(find /etc/* -type l 2> /dev/null); do
|
||||||
if [[ "$(readlink $link)" == /etc/static/* ]]; then
|
f="$(echo $l | sed 's,/etc/,/etc/static/,')"
|
||||||
if [ ! -e "$(readlink -f $link)" ]; then
|
if [ "$(readlink $l)" = "$f" -a ! -e "$(readlink -f $l)" ]; then
|
||||||
rm $link
|
rm "$l"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Reference in a new issue