nixos-config/patches/vaultwarden.patch

40 lines
1.9 KiB
Diff
Raw Normal View History

2023-04-08 22:47:50 +03:00
diff --git a/nixos/modules/services/security/vaultwarden/default.nix b/nixos/modules/services/security/vaultwarden/default.nix
2024-06-27 20:17:07 +03:00
index 41f7de5d8..31c183ed5 100644
2023-04-08 22:47:50 +03:00
--- a/nixos/modules/services/security/vaultwarden/default.nix
+++ b/nixos/modules/services/security/vaultwarden/default.nix
2024-06-27 20:17:07 +03:00
@@ -25,7 +25,7 @@ let
2024-04-23 21:37:10 +03:00
configEnv = lib.concatMapAttrs (name: value: lib.optionalAttrs (value != null) {
${nameToEnvVar name} = if lib.isBool value then lib.boolToString value else toString value;
2023-04-08 22:47:50 +03:00
}) cfg.config;
2024-06-27 20:17:07 +03:00
- in { DATA_FOLDER = "/var/lib/${StateDirectory}"; } // lib.optionalAttrs (!(configEnv ? WEB_VAULT_ENABLED) || configEnv.WEB_VAULT_ENABLED == "true") {
2024-04-23 21:37:10 +03:00
+ in { DATA_FOLDER = cfg.dataDir; } // lib.optionalAttrs (!(configEnv ? WEB_VAULT_ENABLED) || configEnv.WEB_VAULT_ENABLED == "true") {
2023-04-08 22:47:50 +03:00
WEB_VAULT_FOLDER = "${cfg.webVaultPackage}/share/vaultwarden/vault";
} // configEnv;
2024-06-27 20:17:07 +03:00
@@ -157,6 +157,16 @@ in {
2024-04-23 21:37:10 +03:00
defaultText = lib.literalExpression "pkgs.vaultwarden.webvault";
description = "Web vault package to use.";
2023-04-08 22:47:50 +03:00
};
2024-04-23 21:37:10 +03:00
+
+ dataDir = lib.mkOption {
+ type = lib.types.str;
2024-06-27 20:17:07 +03:00
+ default = "/var/lib/${StateDirectory}";
2023-04-08 22:47:50 +03:00
+ description = ''
+ The directury in which vaultwarden will keep its state. If left as the default value
+ this directory will automatically be created before the vaultwarden server starts, otherwise
+ the sysadmin is responsible for ensuring the directory exists with appropriate ownership and permissions.
+ '';
+ };
2024-04-23 21:37:10 +03:00
};
2024-06-27 20:17:07 +03:00
2024-04-23 21:37:10 +03:00
config = lib.mkIf cfg.enable {
2024-06-27 20:17:07 +03:00
@@ -224,7 +234,7 @@ in {
2024-04-23 21:37:10 +03:00
systemd.services.backup-vaultwarden = lib.mkIf (cfg.backupDir != null) {
2023-04-08 22:47:50 +03:00
description = "Backup vaultwarden";
environment = {
2024-06-27 20:17:07 +03:00
- DATA_FOLDER = "/var/lib/${StateDirectory}";
2023-04-25 17:20:58 +03:00
+ DATA_FOLDER = cfg.dataDir;
2023-04-08 22:47:50 +03:00
BACKUP_FOLDER = cfg.backupDir;
};
path = with pkgs; [ sqlite ];