Skip to content

Instantly share code, notes, and snippets.

@sorki
Created February 22, 2021 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorki/5d073110270fcf3a99357d8c46110d88 to your computer and use it in GitHub Desktop.
Save sorki/5d073110270fcf3a99357d8c46110d88 to your computer and use it in GitHub Desktop.
nested NixOS containers
import <nixpkgs/nixos/tests/make-test-python.nix> ({pkgs, ...}: rec {
name = "nesting";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ sorki ];
};
machine = { lib, ... }:
let makeNested = subConf: {
boot.enableContainers = true;
containers.nested = {
autoStart = true;
privateNetwork = true;
config = subConf;
};
};
in makeNested (makeNested {});
testScript = ''
machine.start()
machine.wait_for_unit("container@nested.service")
machine.succeed("systemd-run --pty --machine=nested -- machinectl list | grep nested")
print(
machine.succeed(
"systemd-run --pty --machine=nested -- systemd-run --pty --machine=nested -- systemctl status"
)
)
'';
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment