published
updated
Define a container just like you would any other nixOS configuration
{{{nix { nixosConfigurations.container = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ({pkgs, ...}: {
# Only allow this to boot as a container
boot.isContainer = true;
networking.hostName = "container";
# Allow nginx through the firewall
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx.enable = true;
})
];
}; }; }}}
Run the container from the directory:
sudo nixos-container create test --flake .#container