summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMichael Hoang <enzime@users.noreply.github.com>2024-10-29 00:09:37 +1100
committerMichael Hoang <enzime@users.noreply.github.com>2024-11-07 17:15:22 +1100
commit9afef9950f28780ff24908496c36f27826a601cf (patch)
treec5a7dffe126bb84dfeb3e55c725d1d77c3e5ef70 /modules
parent3ea11449387edeac72fbd7791d106af7553be6e2 (diff)
checks: move manual `/run` instructions to activation
Diffstat (limited to 'modules')
-rw-r--r--modules/system/base.nix54
-rw-r--r--modules/system/checks.nix24
2 files changed, 43 insertions, 35 deletions
diff --git a/modules/system/base.nix b/modules/system/base.nix
index 44a8d91..43c9d7f 100644
--- a/modules/system/base.nix
+++ b/modules/system/base.nix
@@ -2,22 +2,46 @@
{
system.activationScripts.createRun.text = ''
- if ! test -L /run; then
- if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
+ if [[ ! -L /run ]]; then
+ # 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`
+ # wouldn't exist.
+ if [[ -e /etc/synthetic.conf ]]; then
+ if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
echo "setting up /run via /etc/synthetic.conf..."
- echo -e "run\tprivate/var/run" | sudo tee -a /etc/synthetic.conf >/dev/null
- 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 &>/dev/null || true
- if ! test -L /run; then
- echo "warning: apfs.util failed to symlink /run"
- fi
- fi
- if ! test -L /run; then
- echo "setting up /run..."
- sudo ln -sfn private/var/run /run
- fi
- if ! test -L /run; then
- echo "warning: failed to symlink /run"
+ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf >/dev/null
+ fi
+
+ # for Catalina (10.15)
+ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B &>/dev/null || true
+ # for Big Sur (11.0)
+ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t &>/dev/null || true
+
+ if [[ ! -L /run ]]; then
+ printf >&2 'error: apfs.util failed to symlink /run, aborting activation\n'
+ printf >&2 'To create a symlink from /run to /var/run, please run:\n'
+ printf >&2 '\n'
+ 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
+ printf >&2 '\n'
+ printf >&2 'The current contents of /etc/synthetic.conf is:\n'
+ printf >&2 '\n'
+ sudo sed 's/^/ /' /etc/synthetic.conf >&2
+ printf >&2 '\n'
+ exit 1
+ fi
+ else
+ echo "setting up /run..."
+ sudo ln -sfn private/var/run /run
+
+ if [[ ! -L /run ]]; then
+ printf >&2 'error: failed to symlink /run, aborting activation\n'
+ printf >&2 'To create a symlink from /run to /var/run, please run:\n'
+ printf >&2 '\n'
+ printf >&2 '$ sudo ln -sfn private/var/link /run\n'
+ exit 1
+ fi
fi
fi
'';
diff --git a/modules/system/checks.nix b/modules/system/checks.nix
index 497cd9a..6d7ccc0 100644
--- a/modules/system/checks.nix
+++ b/modules/system/checks.nix
@@ -22,25 +22,9 @@ let
'';
runLink = ''
- if ! test -e /run; then
- echo "error: Directory /run does not exist, aborting activation" >&2
- echo "Create a symlink to /var/run with:" >&2
- if test -e /etc/synthetic.conf; then
- echo >&2
- echo "$ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf" >&2
- echo "$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B # For Catalina" >&2
- echo "$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t # For Big Sur and later" >&2
- echo >&2
- echo "The current contents of /etc/synthetic.conf is:" >&2
- echo >&2
- sed 's/^/ /' /etc/synthetic.conf >&2
- echo >&2
- else
- echo >&2
- echo "$ sudo ln -s private/var/run /run" >&2
- echo >&2
- fi
- exit 2
+ if [[ ! -e /run ]]; then
+ printf >&2 'error: directory /run does not exist, aborting activation\n'
+ exit 1
fi
'';
@@ -59,7 +43,7 @@ let
exit 2
fi
'';
-
+
preSequoiaBuildUsers = ''
${lib.optionalString config.nix.configureBuildUsers ''
# Don’t complain when we’re about to migrate old‐style build users…