Skip to content

Instantly share code, notes, and snippets.

@fuad-ibrahimzade
Forked from sorki/containers-nested.nix
Created June 22, 2024 16:18
Show Gist options
  • Save fuad-ibrahimzade/880615337edb6783598730434e64d5b2 to your computer and use it in GitHub Desktop.
Save fuad-ibrahimzade/880615337edb6783598730434e64d5b2 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("[email protected]")
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