[Nix-dev] How do you manage bare-metal local servers with nixops

Christoph Hrdinka c.nix-dev at hrdinka.at
Thu Dec 10 21:38:47 CET 2015


Hi Rohit!

You can use nixops to deploy to any server running ssh. All you have to
do is install a basic NixOS system with opensshd enabled on your target
server. Then tell nixops the hostname/ip address of the new server
via `deployment.targetHost`.

Nixops will evaluate any nix expression you give it. If you supply
multiple files these will be merged. Your nix expression must yield an
attribute set of the following form:

{
  someMachineName =
    { config, lib, pkgs, ... }:
    {
      deployment.targetHost = "hostname or ip";
      # your usual nixos configuration file
      # ...
    }

  anotherMachine =
    {....}
}

Every machine described in there will be deployed according to your
configuation. Since it is a normal nix expression you can use any way
to produce it. You can have basic templates that will be merged and
overwritten by more specific ones, write everything in one file, spread
it over hundret files or write a configuration syntax from which nix
will derive all actual server configs.

For what exactly do you need PXE? Is it for the initial NixOS install
or do you want to use it because it worked for you till now with other
systems?
If you want it because of less configuration work it may be the wrong
tool for a NixOS setup. Nixops is much better suited for this job than
any PXE setup could ever be. It is made for simple deployment of
hundrets of machines.

You might also want to have a look at disnix/disnixos.

Regards,
Christoph Hrdinka.


More information about the nix-dev mailing list