From 0174aa1c564e30eeaab2f0f5e418f060c9009192 Mon Sep 17 00:00:00 2001 From: euxane Date: Thu, 30 May 2024 16:22:03 +0200 Subject: [PATCH] nixos/stalwart-mail: rocksdb as default storage This sets RocksDB as the default storage backend for `stateVersion` >= 24.11. For previous `stateVersion`s, the structured data and blobs remain on SQLite and the filesystem respectively. This is closer to the suggested upstream configuration for fully local storage. --- .../manual/release-notes/rl-2411.section.md | 4 ++++ nixos/modules/services/mail/stalwart-mail.nix | 23 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index e50ec83fa05e..07f7dc914293 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -23,6 +23,10 @@ before changing the package to `pkgs.stalwart-mail` in [`services.stalwart-mail.package`](#opt-services.stalwart-mail.package). +- The `stalwart-mail` module now uses RocksDB as the default storage backend + for `stateVersion` ≥ 24.11. (It was previously using SQLite for structured + data and the filesystem for blobs). + ## Other Notable Changes {#sec-release-24.11-notable-changes} diff --git a/nixos/modules/services/mail/stalwart-mail.nix b/nixos/modules/services/mail/stalwart-mail.nix index 91ae78d7345e..effcc569715d 100644 --- a/nixos/modules/services/mail/stalwart-mail.nix +++ b/nixos/modules/services/mail/stalwart-mail.nix @@ -7,6 +7,7 @@ let configFormat = pkgs.formats.toml { }; configFile = configFormat.generate "stalwart-mail.toml" cfg.settings; dataDir = "/var/lib/stalwart-mail"; + useLegacyStorage = versionOlder config.system.stateVersion "24.11"; in { options.services.stalwart-mail = { @@ -38,14 +39,22 @@ in { }; queue.path = mkDefault "${dataDir}/queue"; report.path = mkDefault "${dataDir}/reports"; - store.db.type = mkDefault "sqlite"; - store.db.path = mkDefault "${dataDir}/data/index.sqlite3"; - store.blob.type = mkDefault "fs"; - store.blob.path = mkDefault "${dataDir}/data/blobs"; + store = if useLegacyStorage then { + # structured data in SQLite, blobs on filesystem + db.type = mkDefault "sqlite"; + db.path = mkDefault "${dataDir}/data/index.sqlite3"; + fs.type = mkDefault "fs"; + fs.path = mkDefault "${dataDir}/data/blobs"; + } else { + # everything in RocksDB + db.type = mkDefault "rocksdb"; + db.path = mkDefault "${dataDir}/db"; + db.compression = mkDefault "lz4"; + }; storage.data = mkDefault "db"; storage.fts = mkDefault "db"; storage.lookup = mkDefault "db"; - storage.blob = mkDefault "blob"; + storage.blob = mkDefault (if useLegacyStorage then "fs" else "db"); directory.internal.type = mkDefault "internal"; directory.internal.store = mkDefault "db"; storage.directory = mkDefault "internal"; @@ -59,8 +68,10 @@ in { wantedBy = [ "multi-user.target" ]; after = [ "local-fs.target" "network.target" ]; - preStart = '' + preStart = if useLegacyStorage then '' mkdir -p ${dataDir}/{queue,reports,data/blobs} + '' else '' + mkdir -p ${dataDir}/{queue,reports,db} ''; serviceConfig = {