Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/containers: Introduce several tweaks to systemd-nspawn from upstream systemd #48771

Merged
merged 1 commit into from Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/system/boot/systemd-nspawn.nix
Expand Up @@ -112,6 +112,7 @@ in {

environment.etc."systemd/nspawn".source = generateUnits "nspawn" units [] [];

systemd.targets."multi-user".wants = [ "machines.target "];
};

}
7 changes: 6 additions & 1 deletion nixos/modules/virtualisation/containers.nix
Expand Up @@ -243,6 +243,9 @@ let

Restart = "on-failure";

Slice = "machine.slice";
Delegate = true;

# Hack: we don't want to kill systemd-nspawn, since we call
# "machinectl poweroff" in preStop to shut down the
# container cleanly. But systemd requires sending a signal
Expand Down Expand Up @@ -657,6 +660,8 @@ in
serviceConfig = serviceDirectives dummyConfig;
};
in {
systemd.targets."multi-user".wants = [ "machines.target" ];

systemd.services = listToAttrs (filter (x: x.value != null) (
# The generic container template used by imperative containers
[{ name = "container@"; value = unit; }]
Expand All @@ -680,7 +685,7 @@ in
} // (
if config.autoStart then
{
wantedBy = [ "multi-user.target" ];
wantedBy = [ "machines.target" ];
wants = [ "network.target" ];
after = [ "network.target" ];
restartTriggers = [ config.path ];
Expand Down