nixos/tests/machinectl: Add declarative shared container

This commit is contained in:
Christian Kögler 2024-03-14 22:07:27 +01:00
parent bdd7e48646
commit f4f99bf8cc

View file

@ -42,8 +42,18 @@ import ./make-test-python.nix ({ pkgs, ... }:
virtualisation.additionalPaths = [ containerSystem ]; virtualisation.additionalPaths = [ containerSystem ];
# not needed, but we want to test the nspawn file generation systemd.tmpfiles.rules = [
systemd.nspawn.${containerName} = { }; "d /var/lib/machines/shared-decl 0755 root root - -"
];
systemd.nspawn.shared-decl = {
execConfig = {
Boot = false;
Parameters = "${containerSystem}/init";
};
filesConfig = {
BindReadOnly = "/nix/store";
};
};
systemd.services."systemd-nspawn@${containerName}" = { systemd.services."systemd-nspawn@${containerName}" = {
serviceConfig.Environment = [ serviceConfig.Environment = [
@ -63,6 +73,11 @@ import ./make-test-python.nix ({ pkgs, ... }:
start_all() start_all()
machine.wait_for_unit("default.target"); machine.wait_for_unit("default.target");
# Test machinectl start stop of shared-decl
machine.succeed("machinectl start shared-decl");
machine.wait_until_succeeds("systemctl -M shared-decl is-active default.target");
machine.succeed("machinectl stop shared-decl");
# create containers root # create containers root
machine.succeed("mkdir -p ${containerRoot}"); machine.succeed("mkdir -p ${containerRoot}");