diff --git a/configurations/host/waffentrager/services/elements.nix b/configurations/host/waffentrager/services/elements.nix index 608df31..1e7da9a 100644 --- a/configurations/host/waffentrager/services/elements.nix +++ b/configurations/host/waffentrager/services/elements.nix @@ -3,6 +3,7 @@ options.waffentragerService.elements.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable elements drive"; options.waffentragerService.elements.path = lib.mkOption { default = "/var/lib/elements"; }; options.waffentragerService.elements.uuid = lib.mkOption { default = "e32039c6-e98d-44b0-8e7d-120994bf7be1"; }; + options.waffentragerService.elements.postgresqlDir = lib.mkOption { default = "${config.waffentragerService.elements.path}/services/postgresql"; }; config = let @@ -19,7 +20,12 @@ mkdir -p ${cfg.path} cryptsetup luksOpen /dev/disk/by-uuid/${cfg.uuid} elements -d ${config.sops.secrets.elements.path} mount /dev/mapper/elements ${cfg.path} - ''; + '' + lib.optionalString config.waffentragerService.postgresql.enable '' + mkdir -p ${config.services.postgresql.dataDir} + chown -R postgres:postgres ${cfg.postgresqlDir} + '' + + ; preStop = '' umount ${cfg.path} cryptsetup luksClose elements diff --git a/configurations/host/waffentrager/services/postgresql.nix b/configurations/host/waffentrager/services/postgresql.nix index 3c7f0bb..7e0f97c 100644 --- a/configurations/host/waffentrager/services/postgresql.nix +++ b/configurations/host/waffentrager/services/postgresql.nix @@ -12,11 +12,11 @@ services.postgresql.enable = true; services.postgresql.package = pkgs.postgresql_16; - services.postgresql.dataDir = "${config.waffentragerService.elements.path}/services/postgresql"; + services.postgresql.dataDir = "${config.waffentragerService.elements.postgresqlDir}/16"; systemd.services.postgresql = { - partOf = ["elements-mount.service"]; - requires = ["elements-mount.service"]; - after = ["elements-mount.service"]; + partOf = [ "elements-mount.service" ]; + requires = [ "elements-mount.service" ]; + after = [ "elements-mount.service" ]; }; }; }