Skip to content

Commit

Permalink
nixos/stalwart-mail: Add dataDir option
Browse files Browse the repository at this point in the history
I want to move it elsewhere.
  • Loading branch information
Artturin committed Dec 26, 2024
1 parent 1557114 commit b19b16b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions nixos/modules/services/mail/stalwart-mail.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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 {
Expand All @@ -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";
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit b19b16b

Please sign in to comment.