Nix-daemon doesn’t start on boot on Ubuntu with multi-user installation and a bind-mounted /nix

Hi all,

I installed nix * on a server running Ubuntu 23.04, with a separate /nix mount. But nix-daemon doesn’t start on boot and I have to do the following manually on each reboot:

sudo systemctl start nix-daemon

/etc/fstab contains the following:

/dev/sda1  /        btrfs     defaults,subvol=@minotaur-root        0       2
/dev/sda1  /nix     btrfs     defaults,subvol=@minotaur-nix         0       2

How can I make the nix-daemon unit depend on the autogenerated nix.mount?

* Note that this only happens with multi-user install and not single-user.
* Also note that I only use one user with nix on this install :wink:

Error trace:

nix-shell -p gradle jdk17 --pure --command "gradle compileTestJava"
error:
       … <borked>

         at «none»:0: (source not available)

       … while evaluating a branch condition

         at /nix/store/jy2pjlczc6pzdv5izjp8a2ya4r7yrdmw-nixpkgs/nixpkgs/pkgs/stdenv/booter.nix:99:7:

           98|     thisStage =
           99|       if args.__raw or false
             |       ^
          100|       then args'

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused

You can probably create a file something like:

# /etc/systemd/system/nix-daemon.service.d/require-mount.conf
[Unit]
RequiresMountsFor=/nix/store
1 Like