diff --git a/nixos/modules/services/mail/stalwart-mail.nix b/nixos/modules/services/mail/stalwart-mail.nix index dca87e7dc2622..d4e650de07db6 100644 --- a/nixos/modules/services/mail/stalwart-mail.nix +++ b/nixos/modules/services/mail/stalwart-mail.nix @@ -8,7 +8,6 @@ let cfg = config.services.stalwart-mail; configFormat = pkgs.formats.toml { }; configFile = configFormat.generate "stalwart-mail.toml" cfg.settings; - dataDir = "/var/lib/stalwart-mail"; useLegacyStorage = lib.versionOlder config.system.stateVersion "24.11"; parsePorts = @@ -46,6 +45,14 @@ in By default, the module is configured to store everything locally. ''; }; + + dataDir = lib.mkOption { + type = lib.types.path; + default = "/var/lib/stalwart-mail"; + description = '' + Data directory for stalwart + ''; + }; }; config = lib.mkIf cfg.enable { @@ -63,15 +70,15 @@ in { # structured data in SQLite, blobs on filesystem db.type = lib.mkDefault "sqlite"; - db.path = lib.mkDefault "${dataDir}/data/index.sqlite3"; + db.path = lib.mkDefault "${cfg.dataDir}/data/index.sqlite3"; fs.type = lib.mkDefault "fs"; - fs.path = lib.mkDefault "${dataDir}/data/blobs"; + fs.path = lib.mkDefault "${cfg.dataDir}/data/blobs"; } else { # everything in RocksDB db.type = lib.mkDefault "rocksdb"; - db.path = lib.mkDefault "${dataDir}/db"; + db.path = lib.mkDefault "${cfg.dataDir}/db"; db.compression = lib.mkDefault "lz4"; }; storage.data = lib.mkDefault "db"; @@ -124,11 +131,11 @@ in preStart = if useLegacyStorage then '' - mkdir -p ${dataDir}/data/blobs + mkdir -p ${cfg.dataDir}/data/blobs '' else '' - mkdir -p ${dataDir}/db + mkdir -p ${cfg.dataDir}/db ''; serviceConfig = {