From d581c42d5d55c612a687cb22db8f748c4f608c7b Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Wed, 16 Oct 2024 22:03:49 -0600 Subject: [PATCH] nixos/paperless: add secretsFile option --- nixos/modules/services/misc/paperless.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index 73f09d804f29..78c7b3c24507 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -37,6 +37,7 @@ let manage = pkgs.writeShellScript "manage" '' set -o allexport # Export the following env vars ${lib.toShellVars env} + ${lib.optionalString (cfg.environmentFile != null) "source ${cfg.environmentFile}"} exec ${cfg.package}/bin/paperless-ngx "$@" ''; @@ -52,6 +53,7 @@ let CapabilityBoundingSet = ""; # ProtectClock adds DeviceAllow=char-rtc r DeviceAllow = ""; + EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile; LockPersonality = true; MemoryDenyWriteExecute = true; NoNewPrivileges = true; @@ -228,6 +230,24 @@ in This sets `OMP_NUM_THREADS` to `1` in order to mitigate the issue. See https://github.com/NixOS/nixpkgs/issues/240591 for more information '' // mkOption { default = true; }; + + environmentFile = mkOption { + type = types.nullOr lib.types.path; + default = null; + example = "/run/secrets/paperless"; + description = '' + Path to a file containing extra paperless config options in the systemd `EnvironmentFile` + format. Refer to the [documentation](https://docs.paperless-ngx.com/configuration/) for + config options. + + This can be used to pass secrets to paperless without putting them in the Nix store. + + To set a database password, point `environmentFile` at a file containing: + ``` + PAPERLESS_DBPASS= + ``` + ''; + }; }; config = mkIf cfg.enable {