mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 01:13:05 +00:00
Merge pull request #114240 from sorki/containers/nested
nixos/nixos-containers: default boot.enableContainers to true
This commit is contained in:
commit
0cc25061b0
@ -439,21 +439,16 @@ in
|
||||
default = false;
|
||||
description = ''
|
||||
Whether this NixOS machine is a lightweight container running
|
||||
in another NixOS system. If set to true, support for nested
|
||||
containers is disabled by default, but can be reenabled by
|
||||
setting <option>boot.enableContainers</option> to true.
|
||||
in another NixOS system.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.enableContainers = mkOption {
|
||||
type = types.bool;
|
||||
default = !config.boot.isContainer;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable support for NixOS containers. Defaults to true
|
||||
(at no cost if containers are not actually used), but only if the
|
||||
system is not itself a lightweight container of a host.
|
||||
To enable support for nested containers, this option has to be
|
||||
explicitly set to true (in the outer container).
|
||||
(at no cost if containers are not actually used).
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -75,6 +75,7 @@ in
|
||||
containers-ip = handleTest ./containers-ip.nix {};
|
||||
containers-macvlans = handleTest ./containers-macvlans.nix {};
|
||||
containers-names = handleTest ./containers-names.nix {};
|
||||
containers-nested = handleTest ./containers-nested.nix {};
|
||||
containers-physical_interfaces = handleTest ./containers-physical_interfaces.nix {};
|
||||
containers-portforward = handleTest ./containers-portforward.nix {};
|
||||
containers-reloadable = handleTest ./containers-reloadable.nix {};
|
||||
|
30
nixos/tests/containers-nested.nix
Normal file
30
nixos/tests/containers-nested.nix
Normal file
@ -0,0 +1,30 @@
|
||||
# Test for NixOS' container nesting.
|
||||
|
||||
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "nested";
|
||||
|
||||
meta = with pkgs.lib.maintainers; { maintainers = [ sorki ]; };
|
||||
|
||||
machine = { lib, ... }:
|
||||
let
|
||||
makeNested = subConf: {
|
||||
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"
|
||||
)
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user