diff --git a/guest/net.paperclover.work-share.plist b/guest/net.paperclover.work-share.plist new file mode 100644 index 0000000000000000000000000000000000000000..b80febdd2feb5e68847ba1a72910df78cc8363e0 --- /dev/null +++ b/guest/net.paperclover.work-share.plist @@ -0,0 +1,19 @@ + + + + + Label + net.paperclover.work-share + ProgramArguments + + /bin/sh + -c +/sbin/mount | /usr/bin/grep -Fq ' on /work (' || /sbin/mount -t nfs -o rw,vers=4,tcp,noresvport,retrycnt=0,intr,sec=sys,nocallback,noowners,rsize=1048576,wsize=1048576,readahead=16,noatime,nosuid,nodev 10.0.0.1:/.work /work || exit 1 +/bin/test -f /work/.snowglobe-work || { /sbin/umount -f /work; exit 1; } + + RunAtLoad + + StartInterval + 30 + + diff --git a/nixos/mac-studio-sandbox.nix b/nixos/mac-studio-sandbox.nix index 40dc790b18bece3f41ad4f513acec45dc0ca3a68..ddc6fea68a22b3470235c845eac24271011c92a4 100644 --- a/nixos/mac-studio-sandbox.nix +++ b/nixos/mac-studio-sandbox.nix @@ -53,6 +53,27 @@ in ${mountPoint} ${workspace.clientAddress}(rw,sync,fsid=0,no_subtree_check,all_squash,anonuid=${toString config.users.users.clo.uid},anongid=${toString config.users.groups.chloe.gid},insecure) ''; }; + environment.etc."exports.d/snowglobe-work.exports".text = '' + ${mountPoint}/.work ${workspace.clientAddress}(rw,sync,fsid=42,no_subtree_check,all_squash,anonuid=${toString config.users.users.clo.uid},anongid=${toString config.users.groups.chloe.gid},insecure) + ''; + systemd.services.mac-work-share-check = { + requires = [ "zfs-import-work.service" ]; + after = [ "zfs-import-work.service" "zfs-mount.service" ]; + serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; + script = '' + test "$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE --mountpoint /srv/work)" = work + ''; + }; + systemd.mounts = [{ + what = "/srv/work"; + where = "${mountPoint}/.work"; + type = "none"; + options = "bind"; + requires = [ "mac-work-share-check.service" "mac-studio-sandbox.service" ]; + after = [ "mac-work-share-check.service" "mac-studio-sandbox.service" ]; + before = [ "nfs-server.service" ]; + wantedBy = [ "multi-user.target" ]; + }]; services.nfs.settings.nfsd = { vers3 = false; "vers4.0" = true; diff --git a/tools/mac-agent-vm.md b/tools/mac-agent-vm.md index c7bb5231dd60dd37efb3e2bdbcb958d98e1dc00f..66f81a2acef9727b324e12444630ed3d1df02098 100644 --- a/tools/mac-agent-vm.md +++ b/tools/mac-agent-vm.md @@ -169,6 +169,12 @@ VM address each time and reuses the existing pinned key configuration. The guest mounts Snow Globe’s NFS export at `/Volumes/Code` using `/etc/fstab`. [net.paperclover.code-share.plist](../guest/net.paperclover.code-share.plist) runs as a system LaunchDaemon at boot and retries every 30 seconds if needed. +The workspace SSD is mounted at `/work` through a separate NFS export, bound +on Snow Globe from `/srv/work` onto the sandbox's `.work` directory; +`/etc/synthetic.d/snowglobe-work` creates the mount point and +[net.paperclover.work-share.plist](../guest/net.paperclover.work-share.plist) +retries the mount every 30 seconds and unmounts it again unless the SSD marker +is present. The guest's `/etc/hosts` maps `file.paperclover.net` to the NAS LAN address `10.0.0.1`. Traffic uses the VM's NAT gateway `192.168.64.1`; the host's hosts