you only need run
if you plan on using https://github.com/LnL7/nix-darwin
- Ensure
sudo vim /etc/synthetic.conf
contains
nix
run
-
Reboot
-
Create
Nix
andRun
APFS Volumes (replace CHANGEME with your disk(example: disk1) and enter the password you want)
sudo diskutil apfs addVolume <CHANGEME|disk1> APFSX Nix -mountpoint /nix -passprompt
sudo diskutil apfs addVolume <CHANGEME|disk1> APFSX Run -mountpoint /run -passprompt
sudo diskutil enableOwnership /nix
sudo diskutil enableOwnership /run
# If you don't want the disk to show on your desktop
sudo chflags hidden /nix
sudo chflags hidden /run
Make sure you update the password to the password you entered earlier
- Create
sudo vim /Users/Shared/mount-nix.sh
and ensure it contains
#!/bin/sh
# This can be cleaned up... but simple for now
echo “<CHANGEME|password>” | diskutil quiet apfs unlock Nix -stdinpassphrase -mountpoint /nix
echo “<CHANGEME|password>” | diskutil quiet apfs unlock Run -stdinpassphrase -mountpoint /run
NOTE: at least on my machine, /Users/Shared
is on a filevaulted drive, so while the password is in plaintext it is owned by root and encrypted at rest
- Ensure the script is executable, and permissions are correct
sudo chmod +x /Users/Shared/mount-nix.sh
sudo chown root:wheel /Users/Shared/mount-nix.sh
NOTE: I created the script in a global launchd location, I don't think this is stricly neccesary but has worked for me and mounts the volumes before GUI apps are brought up See https://www.launchd.info/ and https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
- create
sudo vim /Library/LaunchDaemons/com.<CHANGEME|asdf>.mountnix.plist
and ensure it contains the following(make sure you update<CHANGEME|asdf>
in the file path and the plst content below)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.<CHANGEME|asdf>.mountnix</string>
<key>Disabled</key>
<false/>
<key>UserName</key>
<string>root</string>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/mount-nix.sh</string>
</array>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
- update permissions and load into launchd. Replace
<CHANGEME|asdf>
with your name or whatever you want
sudo chown root:wheel /Library/LaunchDaemons/com.<CHANGME|asdf>.mountnix.plist
sudo launchctl load /Library/LaunchDaemons/com.<CHANGEME|asdf>.mountnix.plist
- Reboot and
Nix
andRun
should be mounted in/nix
and/run
I chose to install nix
in multiuser mode and so far it's worked great
sh <(curl https://nixos.org/nix/install) --daemon
Could probably change
To just
/shrug