When using Time Machine, the "Nix Store" volume will be backed-up just as the Recovery volume, but it won't be restored when restoring a Time Machine Backup in macOS Recovery. However, we can still manually restore the Nix Store volume from a Time Machine backup in macOS by using rsync
or tmutil restore
.
First of all, you'll need to create the Nix Store volume and mount it to /nix
if it isn't ready. On the commands below, we're using the create-darwin-volume.sh
script taken from an PR to let nix installation support macOS 10.15, you can use whatever method suitable under the current era that does the same thing. Just note that it's not needed to do a multi-user Nix installation, if you've done it before in the system, again:
Then, we can use rsync
to restore the Nix Store from our Time Machine backup. We're not using tmutil restore
here because tmutil restore
can't only restore the content within a directory to a specific destination, and will not show the progress while restoring. Note the trailing slash (/
) after Latest/Nix\ Store
, and we're using -p
(--perms
) which restore the file permissions, and -H
(--hard-links
) which respect the hard link structure. You can use --dry-run -vP
first to see what will be transferred:
If you're using a more recent version of rsync
, say installed from Homebrew, you might want to add --info=progress2
to see a progress bar while transferring files: sudo rsync -azpHt [...] --info=progress2
.
To verify the restore, start a new terminal session and type which nix
, you should see the correct output.
Then, start the nix-daemon
manually:
Open another terminal session, then type:
You should see the correct output.
nix-daemon
should be started correctly with launchctl
on the next reboot, or you can start it directly by using sudo launchctl kickstart -k system/org.nixos.nix-daemon
.
💡 You might want to start a fresh new Time Machine backup, by moving the original backup directory in
Backups.backupdb
to another place, after recovering.