aboutsummaryrefslogtreecommitdiff
path: root/scripts/create-darwin-volume.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/create-darwin-volume.sh')
-rwxr-xr-xscripts/create-darwin-volume.sh24
1 files changed, 21 insertions, 3 deletions
diff --git a/scripts/create-darwin-volume.sh b/scripts/create-darwin-volume.sh
index b52232dd3..bd8a7ee3a 100755
--- a/scripts/create-darwin-volume.sh
+++ b/scripts/create-darwin-volume.sh
@@ -440,7 +440,22 @@ add_nix_vol_fstab_line() {
# shellcheck disable=SC1003,SC2026
local escaped_mountpoint="${NIX_ROOT/ /'\\\'040}"
shift
- EDITOR="/usr/bin/ex" _sudo "to add nix to fstab" "$@" <<EOF
+
+ # wrap `ex` to work around a problem with vim plugins breaking exit codes;
+ # (see https://github.com/NixOS/nix/issues/5468)
+ # we'd prefer EDITOR="/usr/bin/ex --noplugin" but vifs doesn't word-split
+ # the EDITOR env.
+ #
+ # TODO: at some point we should switch to `--clean`, but it wasn't added
+ # until https://github.com/vim/vim/releases/tag/v8.0.1554 while the macOS
+ # minver 10.12.6 seems to have released with vim 7.4
+ cat > "$SCRATCH/ex_cleanroom_wrapper" <<EOF
+#!/bin/sh
+/usr/bin/ex --noplugin "\$@"
+EOF
+ chmod 755 "$SCRATCH/ex_cleanroom_wrapper"
+
+ EDITOR="$SCRATCH/ex_cleanroom_wrapper" _sudo "to add nix to fstab" "$@" <<EOF
:a
UUID=$uuid $escaped_mountpoint apfs rw,noauto,nobrowse,suid,owners
.
@@ -631,7 +646,7 @@ EOF
# technically /etc/synthetic.d/nix is supported in Big Sur+
# but handling both takes even more code...
_sudo "to add Nix to /etc/synthetic.conf" \
- /usr/bin/ex /etc/synthetic.conf <<EOF
+ /usr/bin/ex --noplugin /etc/synthetic.conf <<EOF
:a
${NIX_ROOT:1}
.
@@ -742,6 +757,9 @@ setup_volume() {
use_special="${NIX_VOLUME_USE_SPECIAL:-$(create_volume)}"
+ _sudo "to ensure the Nix volume is not mounted" \
+ /usr/sbin/diskutil unmount force "$use_special" || true # might not be mounted
+
use_uuid=${NIX_VOLUME_USE_UUID:-$(volume_uuid_from_special "$use_special")}
setup_fstab "$use_uuid"
@@ -791,7 +809,7 @@ setup_volume_daemon() {
local volume_uuid="$2"
if ! test_voldaemon; then
task "Configuring LaunchDaemon to mount '$NIX_VOLUME_LABEL'" >&2
- _sudo "to install the Nix volume mounter" /usr/bin/ex "$NIX_VOLUME_MOUNTD_DEST" <<EOF
+ _sudo "to install the Nix volume mounter" /usr/bin/ex --noplugin "$NIX_VOLUME_MOUNTD_DEST" <<EOF
:a
$(generate_mount_daemon "$cmd_type" "$volume_uuid")
.