Refactor
This commit is contained in:
@@ -6,22 +6,26 @@ let
|
||||
in{
|
||||
config = lib.mkMerge [{
|
||||
syscfg.server.loadedContainers = lib.mapAttrs (name: containerCfg:
|
||||
(import (./apps + "/${name}.nix")) { inherit config pkgs lib containerCfg builder name; }
|
||||
builder.mkApp name ((import (./apps + "/${name}.nix")) { inherit config pkgs lib containerCfg builder name; })
|
||||
) config.syscfg.server.containers;
|
||||
} (lib.mkIf ( serverCfg.containers != {} ) (
|
||||
let
|
||||
appsList = builtins.attrValues config.syscfg.server.loadedContainers;
|
||||
mergedContainers = lib.concatMapAttrs (appName: app:
|
||||
lib.mapAttrs' (cName: cCfg: lib.nameValuePair "${appName}-${cName}" cCfg) app.containers
|
||||
lib.mapAttrs' (cName: cCfg: lib.nameValuePair "${appName}-${cName}" cCfg) app.runtime.containers
|
||||
) config.syscfg.server.loadedContainers;
|
||||
serverPathConfigs = map (path: {
|
||||
inherit path;
|
||||
mode = "0755";
|
||||
}) (lib.unique (builtins.attrValues serverCfg.path));
|
||||
allPathConfigs = serverPathConfigs ++ 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;
|
||||
allVMConfigs = builtins.filter (app: app.vm != null) appsList;
|
||||
allPathConfigs = serverPathConfigs ++ lib.concatMap (app: app.runtime.paths) appsList;
|
||||
allSetupConfigs = lib.concatMap (app:
|
||||
if app.runtime.setup ? script
|
||||
then [ ({ name = app.name; envFile = ""; } // app.runtime.setup) ]
|
||||
else [ ]
|
||||
) appsList;
|
||||
allCronsConfigs = lib.concatMap (app: app.runtime.cron) appsList;
|
||||
allVMConfigs = builtins.filter (app: app.runtime.vm != null) appsList;
|
||||
in{
|
||||
virtualisation.oci-containers = {
|
||||
backend = "podman";
|
||||
@@ -73,7 +77,7 @@ in{
|
||||
RestartSec = "10s";
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /media/data/kvm";
|
||||
ExecStart = ''
|
||||
${builder.mkVm { name = e.name; vm = e.vm; }}/bin/run-${e.name}-vm -nographic
|
||||
${builder.mkVm { name = e.name; vm = e.runtime.vm; }}/bin/run-${e.name}-vm -nographic
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user