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.

Revisions

  1. @sorki sorki created this gist Feb 22, 2021.
    29 changes: 29 additions & 0 deletions containers-nested.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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"
    )
    )
    '';
    })