diff options
| author | Michael Hoang <enzime@users.noreply.github.com> | 2023-06-20 22:54:31 +1000 |
|---|---|---|
| committer | Michael Hoang <enzime@users.noreply.github.com> | 2023-07-11 18:59:05 +1000 |
| commit | 5288a723540fdb25e34364518115e2ef32ed19ad (patch) | |
| tree | 8211ea859315c329a7e374a65cb3c738da5e7027 /modules/system | |
| parent | f70f90c42207ede0c3b21b785e2650beeecc161c (diff) | |
Allow flaky installation with `darwin-rebuild`
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/activation-scripts.nix | 6 | ||||
| -rw-r--r-- | modules/system/base.nix | 24 | ||||
| -rw-r--r-- | modules/system/checks.nix | 4 |
3 files changed, 27 insertions, 7 deletions
diff --git a/modules/system/activation-scripts.nix b/modules/system/activation-scripts.nix index d5ca292..b92a692 100644 --- a/modules/system/activation-scripts.nix +++ b/modules/system/activation-scripts.nix @@ -69,11 +69,6 @@ in ${cfg.activationScripts.postActivation.text} - # Ensure /run exists. - if [ ! -e /run ]; then - ln -sfn private/var/run /run - fi - # Make this configuration the current configuration. # The readlink is there to ensure that when $systemConfig = /system # (which is a symlink to the store), /run/current-system is still @@ -102,6 +97,7 @@ in ${cfg.activationScripts.preUserActivation.text} + ${cfg.activationScripts.createRun.text} ${cfg.activationScripts.checks.text} ${cfg.activationScripts.extraUserActivation.text} ${cfg.activationScripts.userDefaults.text} diff --git a/modules/system/base.nix b/modules/system/base.nix new file mode 100644 index 0000000..44a8d91 --- /dev/null +++ b/modules/system/base.nix @@ -0,0 +1,24 @@ +{ ... }: + +{ + system.activationScripts.createRun.text = '' + if ! test -L /run; 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" + fi + fi + ''; +} diff --git a/modules/system/checks.nix b/modules/system/checks.nix index b1571ab..f90d9a2 100644 --- a/modules/system/checks.nix +++ b/modules/system/checks.nix @@ -28,8 +28,8 @@ let if test -e /etc/synthetic.conf; then echo >&2 echo "$ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf" >&2 - echo "$ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B # For Catalina" >&2 - echo "$ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t # For Big Sur and later" >&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 |
