Add env file

This commit is contained in:
niten 2024-02-07 15:11:07 -08:00
parent 4a59849ae2
commit f1035af13b
1 changed files with 19 additions and 1 deletions

View File

@ -1,7 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let cfg = config.services.immichContainer; let
cfg = config.services.immichContainer;
hostname = config.instance.hostname;
mkEnvFile = attrs:
concatStringsSep "\n" (mapAttrsToList (k: v: "${k}=${v}") attrs);
databasePassword = pkgs.lib.passwd.stablerandom-passwd-file "immich-db-passwd"
config.instance.build-seed;
in { in {
options.services.immichContainer = with types; { options.services.immichContainer = with types; {
enable = enable =
@ -44,6 +53,15 @@ in {
}; };
config = { config = {
fudo.secrets.host-secrets."${hostname}".immichEnv = {
source-file = mkEnvFile {
DB_USERNAME = "immich";
DB_DATABASE_NAME = "immich";
DB_PASSWORD = readFile databasePassword;
};
target-file = "/run/immich/env";
};
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d ${cfg.state-directory} 0750 root root - -" "d ${cfg.state-directory} 0750 root root - -"
"d ${cfg.store-directory} 0750 root root - -" "d ${cfg.store-directory} 0750 root root - -"