Compare commits
No commits in common. "1d0f51c70ad69b103c630281a75dc65b2776df26" and "84b204f8b1553aa25a0831ec25f03de62df3d7b1" have entirely different histories.
1d0f51c70a
...
84b204f8b1
2 changed files with 14 additions and 55 deletions
|
@ -14,6 +14,5 @@
|
||||||
./qbittorent.nix
|
./qbittorent.nix
|
||||||
./paperless.nix
|
./paperless.nix
|
||||||
./actual.nix
|
./actual.nix
|
||||||
./panoramax.nix
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,40 +6,23 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.panoramax;
|
|
||||||
|
|
||||||
# Database configuration assertions
|
|
||||||
dbUrlConfigured = cfg.database.url != null;
|
|
||||||
individualDbConfigured = all (x: x != null) [
|
|
||||||
cfg.database.host
|
|
||||||
cfg.database.port
|
|
||||||
cfg.database.username
|
|
||||||
cfg.database.password
|
|
||||||
cfg.database.name
|
|
||||||
];
|
|
||||||
|
|
||||||
envContent = ''
|
envContent = ''
|
||||||
# Panoramax Configuration
|
# Panoramax Configuration
|
||||||
FLASK_APP=geovisio
|
FLASK_APP=geovisio
|
||||||
${
|
${optionalString (config.services.panoramax.database.url != null) "DB_URL=${config.services.panoramax.database.url}"}
|
||||||
if dbUrlConfigured
|
${optionalString (config.services.panoramax.database.url == null && config.services.panoramax.database.port != null) "DB_PORT=${toString config.services.panoramax.database.port}"}
|
||||||
then "DB_URL=${cfg.database.url}"
|
${optionalString (config.services.panoramax.database.url == null && config.services.panoramax.database.host != null) "DB_HOST=${config.services.panoramax.database.host}"}
|
||||||
else ''
|
${optionalString (config.services.panoramax.database.url == null && config.services.panoramax.database.username != null) "DB_USERNAME=${config.services.panoramax.database.username}"}
|
||||||
DB_HOST=${cfg.database.host}
|
${optionalString (config.services.panoramax.database.url == null && config.services.panoramax.database.password != null) "DB_PASSWORD=${config.services.panoramax.database.password}"}
|
||||||
DB_PORT=${toString cfg.database.port}
|
${optionalString (config.services.panoramax.database.url == null && config.services.panoramax.database.name != null) "DB_NAME=${config.services.panoramax.database.name}"}
|
||||||
DB_USERNAME=${cfg.database.username}
|
${optionalString (config.services.panoramax.storage.fsUrl != null) "FS_URL=${config.services.panoramax.storage.fsUrl}"}
|
||||||
DB_PASSWORD=${cfg.database.password}
|
${optionalString (config.services.panoramax.infrastructure.nbProxies != null) "INFRA_NB_PROXIES=${toString config.services.panoramax.infrastructure.nbProxies}"}
|
||||||
DB_NAME=${cfg.database.name}
|
${optionalString (config.services.panoramax.flask.secretKey != null) "FLASK_SECRET_KEY=${config.services.panoramax.flask.secretKey}"}
|
||||||
''
|
${optionalString (config.services.panoramax.flask.sessionCookieDomain != null) "FLASK_SESSION_COOKIE_DOMAIN=${config.services.panoramax.flask.sessionCookieDomain}"}
|
||||||
}
|
${optionalString (config.services.panoramax.api.pictures.licenseSpdxId != null) "API_PICTURES_LICENSE_SPDX_ID=${config.services.panoramax.api.pictures.licenseSpdxId}"}
|
||||||
${optionalString (cfg.storage.fsUrl != null) "FS_URL=${cfg.storage.fsUrl}"}
|
${optionalString (config.services.panoramax.api.pictures.licenseUrl != null) "API_PICTURES_LICENSE_URL=${config.services.panoramax.api.pictures.licenseUrl}"}
|
||||||
${optionalString (cfg.infrastructure.nbProxies != null) "INFRA_NB_PROXIES=${toString cfg.infrastructure.nbProxies}"}
|
${optionalString (config.services.panoramax.port != null) "PORT=${toString config.services.panoramax.port}"}
|
||||||
${optionalString (cfg.flask.secretKey != null) "FLASK_SECRET_KEY=${cfg.flask.secretKey}"}
|
${concatStringsSep "\n" (mapAttrsToList (name: value: "${name}=${value}") config.services.panoramax.extraEnvironment)}
|
||||||
${optionalString (cfg.flask.sessionCookieDomain != null) "FLASK_SESSION_COOKIE_DOMAIN=${cfg.flask.sessionCookieDomain}"}
|
|
||||||
${optionalString (cfg.api.pictures.licenseSpdxId != null) "API_PICTURES_LICENSE_SPDX_ID=${cfg.api.pictures.licenseSpdxId}"}
|
|
||||||
${optionalString (cfg.api.pictures.licenseUrl != null) "API_PICTURES_LICENSE_URL=${cfg.api.pictures.licenseUrl}"}
|
|
||||||
${optionalString (cfg.port != null) "PORT=${toString cfg.port}"}
|
|
||||||
${concatStringsSep "\n" (mapAttrsToList (name: value: "${name}=${value}") cfg.extraEnvironment)}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
envFile = pkgs.writeText "panoramax.env" envContent;
|
envFile = pkgs.writeText "panoramax.env" envContent;
|
||||||
|
@ -206,29 +189,6 @@ in {
|
||||||
"d ${config.services.panoramax.storage.fsUrl} 0755 panoramax panoramax -"
|
"d ${config.services.panoramax.storage.fsUrl} 0755 panoramax panoramax -"
|
||||||
];
|
];
|
||||||
|
|
||||||
assertions = [
|
|
||||||
{
|
|
||||||
assertion = dbUrlConfigured || individualDbConfigured;
|
|
||||||
message = ''
|
|
||||||
Panoramax database configuration requires either:
|
|
||||||
- A complete database URL (services.panoramax.database.url), OR
|
|
||||||
- All individual database options (host, port, username, password, name)
|
|
||||||
|
|
||||||
Currently configured:
|
|
||||||
- database.url: ${
|
|
||||||
if dbUrlConfigured
|
|
||||||
then "✓ configured"
|
|
||||||
else "✗ not configured"
|
|
||||||
}
|
|
||||||
- individual options: ${
|
|
||||||
if individualDbConfigured
|
|
||||||
then "✓ all configured"
|
|
||||||
else "✗ some missing"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
# TODO: auto config db
|
# TODO: auto config db
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue