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
|
let
|
||||||
cfg = config.services.podmanPods;
|
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, ... }: {
|
podOptions = { name, config, ... }: {
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "Name of the pod";
|
description = "Name of the pod";
|
||||||
};
|
};
|
||||||
|
|
||||||
ports = mkOption {
|
ports = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "List of port mappings (e.g. ['8080:80'])";
|
description = "List of port mappings (e.g. ['8080:80'])";
|
||||||
};
|
};
|
||||||
|
|
||||||
containers = mkOption {
|
containers = mkOption {
|
||||||
type = types.attrsOf (
|
type = types.attrsOf (types.submodule {
|
||||||
types.submodule
|
options = extendedContainerOptions;
|
||||||
{
|
});
|
||||||
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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
default = { };
|
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
|
create_pod
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
enabledContainers = lib.flatten (mapAttrs
|
||||||
|
(podName: podConfig:
|
||||||
|
filterAttrs (name: value: value.enable or true) podConfig.containers
|
||||||
|
)
|
||||||
|
cfg);
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.podmanPods = mkOption {
|
options.services.podmanPods = mkOption {
|
||||||
|
|
@ -86,18 +93,38 @@ in
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.jq ];
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
|
|
||||||
virtualisation.oci-containers.containers = listToAttrs (flatten (mapAttrsToList
|
virtualisation.oci-containers.containers = enabledContainers;
|
||||||
(podName: podDef:
|
|
||||||
mapAttrsToList
|
# virtualisation.oci-containers.containers = listToAttrs (flatten (mapAttrsToList
|
||||||
(containerName: containerDef:
|
# (podName: podDef:
|
||||||
nameValuePair "${podName}-${containerName}" ({
|
# mapAttrs
|
||||||
inherit (containerDef) image;
|
# (containerName: containerDef:
|
||||||
extraOptions = [ "--pod=${podName}" ] ++ containerDef.extraOptions;
|
# filterAttrs (attrName: attrValue: attrName != "enable") containerDef
|
||||||
})
|
# # nameValuePair "${podName}-${containerName}" ({
|
||||||
)
|
# # inherit (containerDef) image;
|
||||||
podDef.containers
|
# # extraOptions = [ "--pod=${podName}" ] ++ containerDef.extraOptions;
|
||||||
)
|
# # })
|
||||||
cfg));
|
# )
|
||||||
|
# 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
|
networking.firewall.allowedTCPPorts = flatten (mapAttrsToList
|
||||||
(name: podDef:
|
(name: podDef:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue