Use a different dataDir for Hydra?

I want to use Hydra. My /nix/store is on a 256GB SSD, meanwhile I have a 4TB hard disk that I want Hydra to output builds to.

This is the simple overview, and I know the implementation and complexities around store paths is hard. But, is there a simple way to make an instance of Hydra which is operating on the hard disk, rather than on my tiny boot drives?

Perhaps we can run it in a NixOS Container via containers.<name>.config?

I think if you use containers.<name>.config the store is shared with the host.
I am using a configuration where Hydra runs in an independent nspawn container (systemd.nspawn.<name>. config options) to avoid this problem. The container’s store is then fully independent of the host’s nix store.

1 Like

I’m having trouble finding examples of using nspawn containers via the systemd.nspawn.* option. Can you give me one here? Also, I am surprised to hear that they would have their own nix store, wow.

The nspawn container runs as an independent container OS. On the host you define the nspawn settings, e.g.:

systemd.nspawn.myHydra = {
    enable = true;
    execConfig = {
      Boot = true;
      PrivateUsers = false;
    };
    networkConfig = { <bind some interfaces to the container> };
}

Then you can run nixos-install --root /var/lib/machines/myHydra to install NixOS into the container, where the minimal configuration.nix (in /var/lib/machines/myHydra/etc/nixos) for the container should contain:

  boot.isContainer = true;
  boot.loader.initScript.enable = true; # Create /sbin/init, needed for nspawn
1 Like

So, is there no way to declare the entire container like you can with containers.<name>.config? Must I have the imperative step of nixos-install?

I have not found a way to avoid the nixos-install step.