async rebuild
This commit is contained in:
@@ -21,6 +21,17 @@ let
|
|||||||
(map (app: ({ name = app.name; envFile = [ ]; } // app.runtime.setup)) appsList);
|
(map (app: ({ name = app.name; envFile = [ ]; } // app.runtime.setup)) appsList);
|
||||||
allCronsConfigs = concatRuntimeLists "cron";
|
allCronsConfigs = concatRuntimeLists "cron";
|
||||||
allVMConfigs = builtins.filter (app: app.runtime.vm != null) appsList;
|
allVMConfigs = builtins.filter (app: app.runtime.vm != null) appsList;
|
||||||
|
containerUnitNames = map (name: "podman-${name}.service") (builtins.attrNames mergedContainers);
|
||||||
|
setupUnitNames = map (setup: "${setup.name}-setup.service") allSetupConfigs;
|
||||||
|
reconcileUnitNames = containerUnitNames ++ setupUnitNames;
|
||||||
|
reconcileUnits = lib.concatMapStringsSep " " lib.escapeShellArg reconcileUnitNames;
|
||||||
|
reconcileTrigger = pkgs.writeText "syscfg-containers-reconcile-trigger.json" (builtins.toJSON {
|
||||||
|
containers = mergedContainers;
|
||||||
|
setup = map (setup: {
|
||||||
|
inherit (setup) name trigger envFile;
|
||||||
|
script = toString setup.script;
|
||||||
|
}) allSetupConfigs;
|
||||||
|
});
|
||||||
mkPathSetup = cfg:
|
mkPathSetup = cfg:
|
||||||
let
|
let
|
||||||
effectiveCfg = {
|
effectiveCfg = {
|
||||||
@@ -62,12 +73,26 @@ in {
|
|||||||
'';
|
'';
|
||||||
startAt = "weekly";
|
startAt = "weekly";
|
||||||
};
|
};
|
||||||
|
syscfg-containers-reconcile = {
|
||||||
|
description = "Queue OCI container restarts after configuration changes";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
restartTriggers = [ reconcileTrigger ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
${lib.optionalString (reconcileUnitNames != []) ''
|
||||||
|
${pkgs.systemd}/bin/systemctl --no-block restart ${reconcileUnits}
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// builtins.listToAttrs (
|
// builtins.listToAttrs (
|
||||||
map (name: {
|
map (name: {
|
||||||
name = "podman-${name}";
|
name = "podman-${name}";
|
||||||
value.serviceConfig.Type = lib.mkForce "exec";
|
value.restartIfChanged = false;
|
||||||
}) (builtins.attrNames config.virtualisation.oci-containers.containers)
|
}) (builtins.attrNames mergedContainers)
|
||||||
)
|
)
|
||||||
// mkNamedUnits (e: {
|
// mkNamedUnits (e: {
|
||||||
name = "${e.name}-vm";
|
name = "${e.name}-vm";
|
||||||
@@ -99,7 +124,7 @@ in {
|
|||||||
# wants = [ "podman-${e.name}-${e.trigger}.service" ];
|
# wants = [ "podman-${e.name}-${e.trigger}.service" ];
|
||||||
partOf = [ "podman-${e.name}-${e.trigger}.service" ];
|
partOf = [ "podman-${e.name}-${e.trigger}.service" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
restartTriggers = [ e.script ];
|
restartIfChanged = false;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
|
|||||||
Reference in New Issue
Block a user