Kitaab

Using NixOS containers for testing purporses

nix tip

published 2022-09-28 19:10

updated 2022-09-28 19:12

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