diff --git a/nixos/modules/services/security/bitwarden_rs/default.nix b/nixos/modules/services/security/bitwarden_rs/default.nix
index 903a53270377..a04bc883bf0f 100644
--- a/nixos/modules/services/security/bitwarden_rs/default.nix
+++ b/nixos/modules/services/security/bitwarden_rs/default.nix
@@ -81,6 +81,23 @@ in {
the environment template file.
'';
};
+
+ environmentFile = mkOption {
+ type = with types; nullOr path;
+ default = null;
+ example = "/root/bitwarden_rs.env";
+ description = ''
+ Additional environment file as defined in
+ systemd.exec5
+ .
+
+ Secrets like ADMIN_TOKEN and SMTP_PASSWORD
+ may be passed to the service without adding them to the world-readable Nix store.
+
+ Note that this file needs to be available on the host on which
+ bitwarden_rs is running.
+ '';
+ };
};
config = mkIf cfg.enable {
@@ -101,7 +118,7 @@ in {
serviceConfig = {
User = user;
Group = group;
- EnvironmentFile = configFile;
+ EnvironmentFile = [ configFile ] ++ optional (cfg.environmentFile != null) cfg.environmentFile;
ExecStart = "${bitwarden_rs}/bin/bitwarden_rs";
LimitNOFILE = "1048576";
LimitNPROC = "64";