Nixops
Updated: September 28, 2024
Deploy entire systems with Nix.
Use a nix expression to describing machines, network and services.
Like NixOS but done over the network.
Comes with a CLI to deploy and manage servers.
Webserver
Need nixops and virtualbox installed. (best by direnv)
nix-shell -p nixops virtualbox
Create webserver expression
# webserver.nix
network.description = "webserver";
webserver = { config, pkgs, ... }:
{
services = {
httpd = {
enabled = true;
adminAddr = "megacron@d3c3p7.com";
documentRoot = "/home/megacron/public_html";
}:
deployment = {
targetEnv = "virtualbox";
virtualbox = {
memorySize = 2048;
vcpu = 2;
};
};
networking = {
firewall = {
allowedTCPPorts = [ 80 443 ];
};
};
};
}
manage the server with nixops commands
# create a webserver and name it
nixops create -d d3c3p7.com
# list all deployments
nixops list
# get more info
nixops info -d <name | uuid>
# deploy with virtualbox
nixops deploy -d <name | uuid>
Deploy to a NixOS Machine
webserver = { config,pkgs, ... }:
{
deployment.targetHost = "1.2.3.4";
}