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
|
||||
'';
|
||||
|
||||
# flattenPodContainers =
|
||||
# pods:
|
||||
# mapAttrs' (
|
||||
# podName: pod:
|
||||
# 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;
|
||||
enabledContainers =
|
||||
containers:
|
||||
mapAttrs (name: container: removeAttrs container [ "enable" ]) (
|
||||
filterAttrs (name: container: container.enable) containers
|
||||
);
|
||||
|
||||
in
|
||||
{
|
||||
|
|
@ -113,8 +103,10 @@ in
|
|||
|
||||
systemd.services =
|
||||
let
|
||||
podServices = mapAttrs'
|
||||
(
|
||||
|
||||
containers = enabledContainers config.containers;
|
||||
|
||||
podServices = mapAttrs' (
|
||||
name: podDef:
|
||||
nameValuePair "podman-pod-${name}" {
|
||||
description = "Manage Podman pod: ${name}";
|
||||
|
|
@ -129,21 +121,19 @@ in
|
|||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
}
|
||||
)
|
||||
cfg;
|
||||
) cfg;
|
||||
|
||||
containerServices = mapAttrs'
|
||||
(
|
||||
containerServices = mapAttrs' (
|
||||
name: container:
|
||||
nameValuePair "podman-${name}" {
|
||||
after = [ "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" ];
|
||||
}
|
||||
)
|
||||
config.containers;
|
||||
) containers;
|
||||
in
|
||||
podServices // containerServices;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue