Removed comments and format

This commit is contained in:
pazpi 2024-08-27 21:59:21 +02:00
parent 8b25f46384
commit e0a09e90a7
No known key found for this signature in database
GPG key ID: 0942571C4B9966BE
7 changed files with 85 additions and 305 deletions

View file

@ -1,8 +1,7 @@
{
config,
lib,
pkgs,
...
{ config
, lib
, pkgs
, ...
}:
with lib;
@ -10,35 +9,6 @@ with lib;
let
cfg = config.my.virtualisation.podmanPods;
# Get the options from the original oci-containers module
# containerOptions = (
# filterAttrs (
# n: v: n != "definition"
# ) config.virtualisation.oci-containers.containers.type.getSubOptions
# );
# containerDefinition = mkOption {
# type = types.attrs;
# description = "The container definition, derived from virtualisation.oci-containers.containers.";
# example = {
# image = "nginx:latest";
# ports = [ "8080:80" ];
# };
# default = { };
# };
# containerDefinition = mkOption {
# type = types.attrs;
# description = "The container definition, derived from virtualisation.oci-containers.containers.";
# example = {
# image = "nginx:latest";
# ports = [ "8080:80" ];
# };
# default = {};
# };
# # config.virtualisation.oci-containers.containers.type.getSubOptions;
containerDefinition = config.virtualisation.oci-containers.containers.type.getSubOptions;
# Add our enable option
@ -104,12 +74,6 @@ let
fi
'';
# enabledContainers = lib.flatten (
# mapAttrs (
# podName: podConfig: filterAttrs (name: value: value.enable or true) podConfig.containers
# ) cfg
# );
# flattenPodContainers =
# pods:
# mapAttrs' (
@ -140,14 +104,6 @@ in
environment.systemPackages = [ pkgs.jq ];
# virtualisation.oci-containers.containers = enabledContainers;
# virtualisation.oci-containers.containers = flattenPodContainers cfg;
# virtualisation.oci-containers.containers = lib.mkMerge (
# map (entry: entry.container) (filter (entry: entry.enable) cfg.containers)
# );
# virtualisation.oci-containers.containers = listToAttrs (flatten (mapAttrsToList
# (podName: podDef:
# mapAttrs
@ -162,56 +118,45 @@ in
# )
# 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: map (portMapping: lib.toInt (lib.head (lib.splitString ":" portMapping))) podDef.ports
) cfg
mapAttrsToList
(
name: podDef: map (portMapping: lib.toInt (lib.head (lib.splitString ":" portMapping))) podDef.ports
)
cfg
);
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;
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;
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;
in
podServices // containerServices;