diff options
author | Charles Hall <charles@computer.surgery> | 2023-06-06 08:11:49 -0700 |
---|---|---|
committer | Yt <happysalada@tuta.io> | 2023-06-15 06:56:56 -0400 |
commit | b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1 (patch) | |
tree | 0dc5de09f28ab0242dd27b849a8873c4d05f8057 /nixos/modules/services/web-apps/lemmy.nix | |
parent | dd0b5a7e08919a3976d0bdada4d856830f8cd2dc (diff) | |
download | nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.tar nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.tar.gz nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.tar.bz2 nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.tar.lz nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.tar.xz nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.tar.zst nixlib-b1853ecfcda559eb9e62c1a64e45a56e77a8b5d1.zip |
nixos/lemmy: only use env var when instructed
Lemmy checks the environment variable before the configuration file; i.e. if the file is used to configure the database but the environment variable is set to anything, the connection will fail because it'll ignore the file. This was the previous behavior. Now, the environment variable will be unset unless the user explicitly chooses to set it, which makes the file-based configuration function correctly. It's also possible to manually set the environment variable, which has the major advantage of working around [this issue][0], which prevents certain setups from working. [0]: https://github.com/LemmyNet/lemmy/issues/2945
Diffstat (limited to 'nixos/modules/services/web-apps/lemmy.nix')
-rw-r--r-- | nixos/modules/services/web-apps/lemmy.nix | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/nixos/modules/services/web-apps/lemmy.nix b/nixos/modules/services/web-apps/lemmy.nix index 383aa7f5aeb7..88d6b6d2a74d 100644 --- a/nixos/modules/services/web-apps/lemmy.nix +++ b/nixos/modules/services/web-apps/lemmy.nix @@ -27,7 +27,15 @@ in caddy.enable = mkEnableOption (lib.mdDoc "exposing lemmy with the caddy reverse proxy"); nginx.enable = mkEnableOption (lib.mdDoc "exposing lemmy with the nginx reverse proxy"); - database.createLocally = mkEnableOption (lib.mdDoc "creation of database on the instance"); + database = { + createLocally = mkEnableOption (lib.mdDoc "creation of database on the instance"); + + uri = mkOption { + type = with types; nullOr str; + default = null; + description = lib.mdDoc "The connection URI to use. Takes priority over the configuration file if set."; + }; + }; settings = mkOption { default = { }; @@ -190,9 +198,7 @@ in environment = { LEMMY_CONFIG_LOCATION = "/run/lemmy/config.hjson"; - - # Verify how this is used, and don't put the password in the nix store - LEMMY_DATABASE_URL = with cfg.settings.database;"postgres:///${database}?host=${host}"; + LEMMY_DATABASE_URL = mkIf (cfg.database.uri != null) cfg.database.uri; }; documentation = [ |