fix nulls
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
{ config, lib, serverCfg }:
|
{ config, lib, serverCfg }:
|
||||||
let
|
let
|
||||||
builder =
|
builder =
|
||||||
{ image, secret ? ""
|
{ image, secret ? null
|
||||||
, subdomain ? "", ip ? "", port ? 0
|
, subdomain ? null, ip ? null, port ? 0
|
||||||
, extraEnv ? { }, extraLabels ? { }, extraOptions ? [ ]
|
, extraEnv ? { }, extraLabels ? { }, extraOptions ? [ ]
|
||||||
, overrides ? { }
|
, overrides ? { }
|
||||||
}:
|
}:
|
||||||
let base = {
|
let base = {
|
||||||
inherit image;
|
inherit image;
|
||||||
|
|
||||||
environmentFiles = if secret !="" then [ config.sops.secrets."${lib.toUpper secret}".path ] else [];
|
environmentFiles = if secret then [ config.sops.secrets."${lib.toUpper secret}".path ] else [];
|
||||||
environment = {} // extraEnv;
|
environment = {} // extraEnv;
|
||||||
|
|
||||||
labels = if subdomain!="" then ({
|
labels = if subdomain then ({
|
||||||
"traefik.enable" = "true";
|
"traefik.enable" = "true";
|
||||||
"traefik.http.routers.${subdomain}.entrypoints" = "web-secure";
|
"traefik.http.routers.${subdomain}.entrypoints" = "web-secure";
|
||||||
"traefik.http.routers.${subdomain}.rule" = "Host(`${subdomain}.${serverCfg.hostDomain}`)";
|
"traefik.http.routers.${subdomain}.rule" = "Host(`${subdomain}.${serverCfg.hostDomain}`)";
|
||||||
"traefik.http.routers.${subdomain}.tls" = "true";
|
"traefik.http.routers.${subdomain}.tls" = "true";
|
||||||
} // lib.optionalAttrs (port != 0) {
|
} // lib.optionalAttrs (port) {
|
||||||
"traefik.http.services.${subdomain}.loadbalancer.server.port" = toString port;
|
"traefik.http.services.${subdomain}.loadbalancer.server.port" = toString port;
|
||||||
}) else {
|
}) else {
|
||||||
"traefik.enable" = "false";
|
"traefik.enable" = "false";
|
||||||
@@ -25,7 +25,7 @@ let
|
|||||||
|
|
||||||
extraOptions = extraOptions ++ [
|
extraOptions = extraOptions ++ [
|
||||||
"--add-host=host.containers.internal:host-gateway"
|
"--add-host=host.containers.internal:host-gateway"
|
||||||
] ++ lib.optional (ip != "") "--ip=${ip}";
|
] ++ lib.optional (ip) "--ip=${ip}";
|
||||||
};
|
};
|
||||||
in lib.recursiveUpdate base overrides;
|
in lib.recursiveUpdate base overrides;
|
||||||
in {
|
in {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ in {
|
|||||||
};
|
};
|
||||||
overrides = {
|
overrides = {
|
||||||
cmd = [ "server" ];
|
cmd = [ "server" ];
|
||||||
ports = if containerCfg.pubPort != 0 && containerCfg.port != 0 then [ "${toString containerCfg.pubPort}:${toString containerCfg.port}" ] else [];
|
ports = if containerCfg.pubPort && containerCfg.port then [ "${toString containerCfg.pubPort}:${toString containerCfg.port}" ] else [];
|
||||||
volumes = [
|
volumes = [
|
||||||
"${serverCfg.configPath}/authentik/media:/media"
|
"${serverCfg.configPath}/authentik/media:/media"
|
||||||
"${serverCfg.configPath}/authentik/templates:/templates"
|
"${serverCfg.configPath}/authentik/templates:/templates"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ in {
|
|||||||
"--tmpfs /tmp:rw,mode=1777"
|
"--tmpfs /tmp:rw,mode=1777"
|
||||||
];
|
];
|
||||||
overrides = {
|
overrides = {
|
||||||
ports = if containerCfg.pubPort != 0 && containerCfg.port != 0 then [ "${toString containerCfg.pubPort}:${toString containerCfg.port}" ] else [];
|
ports = if containerCfg.pubPort && containerCfg.port then [ "${toString containerCfg.pubPort}:${toString containerCfg.port}" ] else [];
|
||||||
volumes = [
|
volumes = [
|
||||||
"${serverCfg.dataPath}/nextcloud/www:/var/www/html"
|
"${serverCfg.dataPath}/nextcloud/www:/var/www/html"
|
||||||
"${serverCfg.dataPath}/nextcloud/data:/var/www/html/data"
|
"${serverCfg.dataPath}/nextcloud/data:/var/www/html/data"
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ let
|
|||||||
sops = mkOption { type = types.bool;default = false; };
|
sops = mkOption { type = types.bool;default = false; };
|
||||||
ip = mkOption { type = types.nullOr types.str; default = null;};
|
ip = mkOption { type = types.nullOr types.str; default = null;};
|
||||||
subdomain = mkOption { type = types.nullOr types.str; default=null;};
|
subdomain = mkOption { type = types.nullOr types.str; default=null;};
|
||||||
port = mkOption { type = types.port; default = 0; };
|
port = mkOption { type = types.nullOr types.port; default = null; };
|
||||||
pubPort = mkOption { type = types.port; default = 0; };
|
pubPort = mkOption { type = types.nullOr types.port; default = null; };
|
||||||
extraParam = mkOption { type = types.str; default = ""; };
|
extraParam = mkOption { type = types.str; default = ""; };
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user