diff --git a/modules/virtualisation/podman-pod.nix b/modules/virtualisation/podman-pod.nix index e77ca4f..b12689a 100644 --- a/modules/virtualisation/podman-pod.nix +++ b/modules/virtualisation/podman-pod.nix @@ -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,37 +103,37 @@ in systemd.services = let - podServices = mapAttrs' - ( - name: podDef: - nameValuePair "podman-pod-${name}" { - description = "Manage Podman pod: ${name}"; - serviceConfig = { - Type = "oneshot"; - ExecStart = "${createPodScript name podDef}"; - }; - path = [ - pkgs.jq - pkgs.podman - ]; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - } - ) - cfg; - 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 = enabledContainers config.containers; + + podServices = mapAttrs' ( + name: podDef: + nameValuePair "podman-pod-${name}" { + description = "Manage Podman pod: ${name}"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${createPodScript name podDef}"; + }; + path = [ + pkgs.jq + pkgs.podman + ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + } + ) cfg; + + 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" ]; + } + ) containers; in podServices // containerServices; }; + }