WIP: error infinite recursion for oci-container
This commit is contained in:
parent
0bac6ba223
commit
9d6925d720
1 changed files with 56 additions and 29 deletions
|
|
@ -6,37 +6,37 @@ with lib;
|
|||
let
|
||||
cfg = config.services.podmanPods;
|
||||
|
||||
# Get the options from the original oci-containers module
|
||||
containerOptions = (filterAttrs (n: v: n != "definition")
|
||||
config.virtualisation.oci-containers.containers.type.getSubOptions);
|
||||
|
||||
# Add our enable option
|
||||
extendedContainerOptions = containerOptions // {
|
||||
enable = mkEnableOption "Enable this container";
|
||||
};
|
||||
|
||||
podOptions = { name, config, ... }: {
|
||||
options = {
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
description = "Name of the pod";
|
||||
};
|
||||
|
||||
ports = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "List of port mappings (e.g. ['8080:80'])";
|
||||
};
|
||||
|
||||
containers = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.submodule
|
||||
{
|
||||
options = {
|
||||
image = mkOption {
|
||||
type = types.str;
|
||||
description = "Docker image for the container";
|
||||
};
|
||||
extraOptions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Additional options for the container";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = extendedContainerOptions;
|
||||
});
|
||||
default = { };
|
||||
description = "Containers to run in the pod";
|
||||
description = "Attribute set of OCI container configurations for this set";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -72,6 +72,13 @@ let
|
|||
create_pod
|
||||
fi
|
||||
'';
|
||||
|
||||
enabledContainers = lib.flatten (mapAttrs
|
||||
(podName: podConfig:
|
||||
filterAttrs (name: value: value.enable or true) podConfig.containers
|
||||
)
|
||||
cfg);
|
||||
|
||||
in
|
||||
{
|
||||
options.services.podmanPods = mkOption {
|
||||
|
|
@ -86,18 +93,38 @@ in
|
|||
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
|
||||
virtualisation.oci-containers.containers = listToAttrs (flatten (mapAttrsToList
|
||||
(podName: podDef:
|
||||
mapAttrsToList
|
||||
(containerName: containerDef:
|
||||
nameValuePair "${podName}-${containerName}" ({
|
||||
inherit (containerDef) image;
|
||||
extraOptions = [ "--pod=${podName}" ] ++ containerDef.extraOptions;
|
||||
})
|
||||
)
|
||||
podDef.containers
|
||||
)
|
||||
cfg));
|
||||
virtualisation.oci-containers.containers = enabledContainers;
|
||||
|
||||
# virtualisation.oci-containers.containers = listToAttrs (flatten (mapAttrsToList
|
||||
# (podName: podDef:
|
||||
# mapAttrs
|
||||
# (containerName: containerDef:
|
||||
# filterAttrs (attrName: attrValue: attrName != "enable") containerDef
|
||||
# # nameValuePair "${podName}-${containerName}" ({
|
||||
# # inherit (containerDef) image;
|
||||
# # extraOptions = [ "--pod=${podName}" ] ++ containerDef.extraOptions;
|
||||
# # })
|
||||
# )
|
||||
# podDef.containers
|
||||
# )
|
||||
# cfg));
|
||||
|
||||
# virtualisation.oci-containers.containers = lib.flatten
|
||||
# (mapAttrs
|
||||
# (podName: podConfig:
|
||||
# mapAttrs
|
||||
# (containerName: containerConfig:
|
||||
# filterAttrs (attrName: attrValue: attrName != "enable") containerConfig
|
||||
# )
|
||||
# (filterAttrs (name: value: value.enable) podConfig.containers)
|
||||
# )
|
||||
# (filterAttrs (podName: podConfig: podConfig.enable) cfg)
|
||||
# );
|
||||
# mapAttrs
|
||||
# (name: value:
|
||||
# filterAttrs (n: v: n != "enable") value
|
||||
# )
|
||||
# (filterAttrs (name: value: value.enable) cfg.containers);
|
||||
|
||||
networking.firewall.allowedTCPPorts = flatten (mapAttrsToList
|
||||
(name: podDef:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue