Update modules/server/containers/default.nix
This commit is contained in:
@@ -15,14 +15,13 @@ in{
|
|||||||
lib.mapAttrs' (cName: cCfg: lib.nameValuePair "${appName}-${cName}" cCfg) app.containers
|
lib.mapAttrs' (cName: cCfg: lib.nameValuePair "${appName}-${cName}" cCfg) app.containers
|
||||||
) config.syscfg.server.loadedContainers;
|
) config.syscfg.server.loadedContainers;
|
||||||
allPathConfigs = lib.concatMap (app: app.paths) appsList;
|
allPathConfigs = lib.concatMap (app: app.paths) appsList;
|
||||||
|
allSetupConfigs = lib.concatMap (app: if app.setup?script then [({name = app.name; envFile="";} // app.setup)] else []) appsList;
|
||||||
allCronsConfigs = lib.concatMap (app: app.cron) appsList;
|
allCronsConfigs = lib.concatMap (app: app.cron) appsList;
|
||||||
in{
|
in{
|
||||||
|
|
||||||
virtualisation.oci-containers = {
|
virtualisation.oci-containers = {
|
||||||
backend = "podman";
|
backend = "podman";
|
||||||
containers = mergedContainers;
|
containers = mergedContainers;
|
||||||
};
|
};
|
||||||
|
|
||||||
system.activationScripts.container-setup-dirs = {
|
system.activationScripts.container-setup-dirs = {
|
||||||
deps = [ "users" "groups" ];
|
deps = [ "users" "groups" ];
|
||||||
text = lib.concatStringsSep "\n" (map (cfg:
|
text = lib.concatStringsSep "\n" (map (cfg:
|
||||||
@@ -48,25 +47,23 @@ in{
|
|||||||
'';
|
'';
|
||||||
startAt = "weekly";
|
startAt = "weekly";
|
||||||
};
|
};
|
||||||
} // lib.listToAttrs (lib.concatMap (containerSet:
|
} // lib.listToAttrs (lib.concatMap (e: [{
|
||||||
if containerSet.setup.script != null then [{
|
name = "${e.name}-setup";
|
||||||
name = "${containerSet.name}-setup";
|
|
||||||
value = {
|
value = {
|
||||||
description = "Run ${containerSet.name} setup";
|
description = "Run ${e.name} setup";
|
||||||
after = [ "podman-${containerSet.name}-${containerSet.setup.trigger}.service" ];
|
after = [ "podman-${e.name}-${e.trigger}.service" ];
|
||||||
wants = [ "podman-${containerSet.name}-${containerSet.setup.trigger}.service" ];
|
wants = [ "podman-${e.name}-${e.trigger}.service" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
TimeoutStartSec = "360s";
|
TimeoutStartSec = "360s";
|
||||||
EnvironmentFile = if (containerSet.setup ? envFile) then containerSet.setup.envFile else [ ];
|
EnvironmentFile = e.envFile;
|
||||||
ExecStart = "${containerSet.setup.script}";
|
ExecStart = e.script;
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
User = "root";
|
User = "root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}] else []
|
}]) allSetupConfigs );
|
||||||
) appsList);
|
|
||||||
|
|
||||||
services.cron = {
|
services.cron = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user