mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
system: always add /run to /etc/synthetic.conf on macOS 10.15 onwards
Currently if nix-darwin is uninstalled then reinstalled without rebooting, then the `/run` symlink will still remain and nix-darwin won't readd `run` to `/etc/synthetic.conf` meaning the system will be broken on next reboot.
This commit is contained in:
parent
61cee20168
commit
57c144515a
1 changed files with 38 additions and 35 deletions
|
@ -2,28 +2,32 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
system.activationScripts.createRun.text = ''
|
system.activationScripts.createRun.text = ''
|
||||||
if [[ ! -L /run ]]; then
|
IFS="." read -r -a macOSVersion <<< "$(sw_vers -productVersion)"
|
||||||
# This file doesn't exist by default on macOS and is only supported after 10.15
|
|
||||||
# however every system with Nix installed should have this file otherwise `/nix`
|
if [[ ''${macOSVersion[0]} -gt 10 || ( ''${macOSVersion[0]} -eq 10 && ''${macOSVersion[1]} -ge 15 ) ]]; then
|
||||||
# wouldn't exist.
|
|
||||||
if [[ -e /etc/synthetic.conf ]]; then
|
|
||||||
if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
|
if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
|
||||||
echo "setting up /run via /etc/synthetic.conf..."
|
echo "setting up /run via /etc/synthetic.conf..."
|
||||||
printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf >/dev/null
|
printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# for Catalina (10.15)
|
if [[ ''${macOSVersion[0]} -gt 10 ]]; then
|
||||||
sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B &>/dev/null || true
|
sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t || true
|
||||||
# for Big Sur (11.0)
|
else
|
||||||
sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t &>/dev/null || true
|
sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B || true
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -L /run ]]; then
|
if [[ ! -L /run ]]; then
|
||||||
printf >&2 '[1;31merror: apfs.util failed to symlink /run, aborting activation[0m\n'
|
printf >&2 '[1;31merror: apfs.util failed to symlink /run, aborting activation[0m\n'
|
||||||
printf >&2 'To create a symlink from /run to /var/run, please run:\n'
|
printf >&2 'To create a symlink from /run to /var/run, please run:\n'
|
||||||
printf >&2 '\n'
|
printf >&2 '\n'
|
||||||
printf >&2 "$ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf"
|
printf >&2 "$ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf"
|
||||||
printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B # For Catalina\n'
|
|
||||||
printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t # For Big Sur and later\n' >&2
|
if [[ ''${macOSVersion[0]} -gt 10 ]]; then
|
||||||
|
printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t\n'
|
||||||
|
else
|
||||||
|
printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B\n'
|
||||||
|
fi
|
||||||
|
|
||||||
printf >&2 '\n'
|
printf >&2 '\n'
|
||||||
printf >&2 'The current contents of /etc/synthetic.conf is:\n'
|
printf >&2 'The current contents of /etc/synthetic.conf is:\n'
|
||||||
printf >&2 '\n'
|
printf >&2 '\n'
|
||||||
|
@ -43,6 +47,5 @@
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue