Skip to content

Commit ddab975

Browse files
Titaniumtownntninja
andcommitted
syncstorage-rs: split into syncstorage-rs-{mysql,pgsql}
Expose both database backends as top-level packages so Hydra builds and caches each variant. The firefox-syncserver module now picks the appropriate package based on `services.firefox-syncserver.database.type` when the user does not supply one explicitly. The `package` option becomes `nullOr package` with a `null` default; this avoids requiring a user-supplied custom package to implement the `dbBackend` override attribute. Co-authored-by: Alexander Schlarb <alexander@ninetailed.ninja>
1 parent 9f03b92 commit ddab975

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

nixos/modules/services/networking/firefox-syncserver.nix

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ let
2727
# where the syncserver starts before its database and role exist.
2828
dbService = if dbIsMySQL then "mysql.service" else "postgresql.target";
2929

30-
syncserver = cfg.package.override { dbBackend = cfg.database.type; };
30+
syncserver =
31+
if cfg.package != null then
32+
cfg.package
33+
else if dbIsMySQL then
34+
pkgs.syncstorage-rs-mysql
35+
else
36+
pkgs.syncstorage-rs-pgsql;
3137

3238
format = pkgs.formats.toml { };
3339
settings = {
@@ -139,7 +145,20 @@ in
139145
{option}`${opt.singleNode.enable}` does this automatically when enabled
140146
'';
141147

142-
package = lib.mkPackageOption pkgs "syncstorage-rs" { };
148+
package = lib.mkOption {
149+
type = lib.types.nullOr lib.types.package;
150+
default = null;
151+
defaultText = lib.literalExpression ''
152+
if config.${opt.database.type} == "mysql" then
153+
pkgs.syncstorage-rs-mysql
154+
else
155+
pkgs.syncstorage-rs-pgsql
156+
'';
157+
description = ''
158+
Syncstorage server package to use. When `null`, the package is
159+
selected automatically based on {option}`${opt.database.type}`.
160+
'';
161+
};
143162

144163
database.type = lib.mkOption {
145164
type = lib.types.enum [

pkgs/by-name/sy/syncstorage-rs/package.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ rustPlatform.buildRustPackage (finalAttrs: {
8484

8585
passthru.updateScript = nix-update-script { };
8686

87-
passthru.tests = { inherit (nixosTests) firefox-syncserver; };
87+
passthru.tests = {
88+
firefox-syncserver = nixosTests.firefox-syncserver.${if dbBackend == "postgresql" then "postgresql" else "mysql"};
89+
};
8890

8991
meta = {
9092
description = "Mozilla Sync Storage built with Rust";

pkgs/top-level/all-packages.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10535,6 +10535,9 @@ with pkgs;
1053510535
waylandSupport = true;
1053610536
};
1053710537

10538+
syncstorage-rs-mysql = callPackage ../by-name/sy/syncstorage-rs/package.nix { dbBackend = "mysql"; };
10539+
syncstorage-rs-pgsql = callPackage ../by-name/sy/syncstorage-rs/package.nix { dbBackend = "postgresql"; };
10540+
1053810541
inherit
1053910542
(callPackages ../applications/networking/syncthing {
1054010543
inherit (darwin) autoSignDarwinBinariesHook;

0 commit comments

Comments
 (0)