create systemd unit only for enabled container
This commit is contained in:
parent
7811654fb7
commit
3bdf838524
1 changed files with 33 additions and 43 deletions
|
|
@ -75,21 +75,11 @@ let
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# flattenPodContainers =
|
enabledContainers =
|
||||||
# pods:
|
containers:
|
||||||
# mapAttrs' (
|
mapAttrs (name: container: removeAttrs container [ "enable" ]) (
|
||||||
# podName: pod:
|
filterAttrs (name: container: container.enable) containers
|
||||||
# mapAttrs' (
|
);
|
||||||
# containerName: container:
|
|
||||||
# nameValuePair "${podName}-${containerName}" (
|
|
||||||
# container
|
|
||||||
# # // {
|
|
||||||
# # inherit (pod) name;
|
|
||||||
# # extraOptions = (container.extraOptions or [ ]) ++ [ "--pod=${pod.name}" ];
|
|
||||||
# # }
|
|
||||||
# )
|
|
||||||
# ) (filterAttrs (n: v: v.enable or true) pod.containers)
|
|
||||||
# ) pods;
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -113,8 +103,10 @@ in
|
||||||
|
|
||||||
systemd.services =
|
systemd.services =
|
||||||
let
|
let
|
||||||
podServices = mapAttrs'
|
|
||||||
(
|
containers = enabledContainers config.containers;
|
||||||
|
|
||||||
|
podServices = mapAttrs' (
|
||||||
name: podDef:
|
name: podDef:
|
||||||
nameValuePair "podman-pod-${name}" {
|
nameValuePair "podman-pod-${name}" {
|
||||||
description = "Manage Podman pod: ${name}";
|
description = "Manage Podman pod: ${name}";
|
||||||
|
|
@ -129,21 +121,19 @@ in
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
}
|
}
|
||||||
)
|
) cfg;
|
||||||
cfg;
|
|
||||||
|
|
||||||
containerServices = mapAttrs'
|
containerServices = mapAttrs' (
|
||||||
(
|
|
||||||
name: container:
|
name: container:
|
||||||
nameValuePair "podman-${name}" {
|
nameValuePair "podman-${name}" {
|
||||||
after = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ];
|
after = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ];
|
||||||
requires = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ];
|
requires = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ];
|
||||||
partOf = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ];
|
partOf = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ];
|
||||||
}
|
}
|
||||||
)
|
) containers;
|
||||||
config.containers;
|
|
||||||
in
|
in
|
||||||
podServices // containerServices;
|
podServices // containerServices;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue