mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
Merge pull request #62779 from grahamc/containers-restart
Restart declarative containers when their host environment configuration changes
This commit is contained in:
commit
9d11c30cf9
@ -689,7 +689,7 @@ in
|
||||
[{ name = "container@"; value = unit; }]
|
||||
# declarative containers
|
||||
++ (mapAttrsToList (name: cfg: nameValuePair "container@${name}" (let
|
||||
config = cfg // (
|
||||
containerConfig = cfg // (
|
||||
if cfg.enableTun then
|
||||
{
|
||||
allowedDevices = cfg.allowedDevices
|
||||
@ -700,18 +700,21 @@ in
|
||||
else {});
|
||||
in
|
||||
unit // {
|
||||
preStart = preStartScript config;
|
||||
script = startScript config;
|
||||
postStart = postStartScript config;
|
||||
serviceConfig = serviceDirectives config;
|
||||
preStart = preStartScript containerConfig;
|
||||
script = startScript containerConfig;
|
||||
postStart = postStartScript containerConfig;
|
||||
serviceConfig = serviceDirectives containerConfig;
|
||||
} // (
|
||||
if config.autoStart then
|
||||
if containerConfig.autoStart then
|
||||
{
|
||||
wantedBy = [ "machines.target" ];
|
||||
wants = [ "network.target" ];
|
||||
after = [ "network.target" ];
|
||||
restartTriggers = [ config.path ];
|
||||
reloadIfChanged = true;
|
||||
restartTriggers = [
|
||||
containerConfig.path
|
||||
config.environment.etc."containers/${name}.conf".source
|
||||
];
|
||||
restartIfChanged = true;
|
||||
}
|
||||
else {})
|
||||
)) config.containers)
|
||||
|
Loading…
Reference in New Issue
Block a user