setup scripts
This commit is contained in:
@@ -6,10 +6,12 @@ let
|
||||
containerSetsList = lib.mapAttrsToList (name: containerCfg:
|
||||
let defs = import (./defs + "/${name}.nix") {inherit config pkgs lib containerCfg builder name;};
|
||||
in{
|
||||
name = name;
|
||||
containers = lib.mapAttrs' (cName: cValue:
|
||||
lib.nameValuePair "${name}-${cName}" cValue
|
||||
) defs.containers;
|
||||
paths = defs.paths or [];
|
||||
setup = defs.setup or null;
|
||||
}
|
||||
) enabledConfigs;
|
||||
mergedContainers = lib.attrsets.mergeAttrsList (lib.map(e: e.containers) containerSetsList);
|
||||
@@ -24,15 +26,7 @@ in
|
||||
containers = mergedContainers;
|
||||
};
|
||||
|
||||
systemd.services.podman-gc = {
|
||||
description = "Podman garbage collection";
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
${pkgs.podman}/bin/podman container prune -f
|
||||
${pkgs.podman}/bin/podman image prune -f
|
||||
'';
|
||||
startAt = "weekly";
|
||||
};
|
||||
systemd.services
|
||||
|
||||
system.activationScripts.container-setup-dirs = {
|
||||
deps = [ "users" "groups" ];
|
||||
@@ -42,5 +36,46 @@ in
|
||||
${pkgs.coreutils}/bin/chmod ${cfg.mode} "${cfg.path}"
|
||||
'') allPathConfigs);
|
||||
};
|
||||
|
||||
|
||||
# systemd.services.${name}-init-settings = {
|
||||
# description = "Initialize ${NAME} settings";
|
||||
# after = [ "podman-${name}-${setup.trigger}.service" ];
|
||||
# requires = [ "podman-${name}-${setup.trigger}.service" ];
|
||||
# wantedBy = [ "multi-user.target" ];
|
||||
# serviceConfig = {
|
||||
# Type = "oneshot";
|
||||
# ExecStart = "${container.setup.script}";
|
||||
# RemainAfterExit = true;
|
||||
# };
|
||||
# };
|
||||
systemd.services = {
|
||||
podman-gc = {
|
||||
description = "Podman garbage collection";
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
${pkgs.podman}/bin/podman container prune -f
|
||||
${pkgs.podman}/bin/podman image prune -f
|
||||
'';
|
||||
startAt = "weekly";
|
||||
};
|
||||
} // lib.listToAttrs (lib.concatMap (containerSet:
|
||||
if containerSet.setup != null then [{
|
||||
name = "${containerSet.name}-setup";
|
||||
value = {
|
||||
description = "Run ${containerSet.name} setup";
|
||||
after = [ "podman-${containerSet.name}-${containerSet.setup.trigger}.service" ];
|
||||
requires = [ "podman-${containerSet.name}-${containerSet.setup.trigger}.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${containerSet.setup.script}";
|
||||
RemainAfterExit = true;
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
}] else []
|
||||
) containerSetsList);
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user