Skip to content

Commit fcc613a

Browse files
committed
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.
1 parent d0056c5 commit fcc613a

3 files changed

Lines changed: 34 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
@@ -32,7 +32,13 @@ let
3232
# where the syncserver starts before its database and role exist.
3333
dbService = if dbIsMySQL then "mysql.service" else "postgresql.target";
3434

35-
syncserver = cfg.package.override { dbBackend = cfg.database.type; };
35+
syncserver =
36+
if cfg.package != null then
37+
cfg.package
38+
else if dbIsMySQL then
39+
pkgs.syncstorage-rs-mysql
40+
else
41+
pkgs.syncstorage-rs-pgsql;
3642

3743
format = pkgs.formats.toml { };
3844
settings = {
@@ -151,7 +157,20 @@ in
151157
{option}`${opt.singleNode.enable}` does this automatically when enabled
152158
'';
153159

154-
package = lib.mkPackageOption pkgs "syncstorage-rs" { };
160+
package = lib.mkOption {
161+
type = lib.types.nullOr lib.types.package;
162+
default = null;
163+
defaultText = lib.literalExpression ''
164+
if config.${opt.database.type} == "mysql" then
165+
pkgs.syncstorage-rs-mysql
166+
else
167+
pkgs.syncstorage-rs-pgsql
168+
'';
169+
description = ''
170+
Syncstorage server package to use. When `null`, the package is
171+
selected automatically based on {option}`${opt.database.type}`.
172+
'';
173+
};
155174

156175
database.type = lib.mkOption {
157176
type = lib.types.enum [

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ rustPlatform.buildRustPackage (finalAttrs: {
3535
pname = "syncstorage-rs";
3636
version = "0.22.2";
3737

38+
__structuredAttrs = true;
39+
3840
src = fetchFromGitHub {
3941
owner = "mozilla-services";
4042
repo = "syncstorage-rs";
@@ -86,7 +88,10 @@ rustPlatform.buildRustPackage (finalAttrs: {
8688

8789
passthru.updateScript = nix-update-script { };
8890

89-
passthru.tests = { inherit (nixosTests) firefox-syncserver; };
91+
passthru.tests = {
92+
firefox-syncserver =
93+
nixosTests.firefox-syncserver.${if dbBackend == "postgresql" then "postgresql" else "mysql"};
94+
};
9095

9196
meta = {
9297
description = "Mozilla Sync Storage built with Rust";

pkgs/top-level/all-packages.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9461,6 +9461,13 @@ with pkgs;
94619461
waylandSupport = true;
94629462
};
94639463

9464+
syncstorage-rs-mysql = callPackage ../by-name/sy/syncstorage-rs/package.nix {
9465+
dbBackend = "mysql";
9466+
};
9467+
syncstorage-rs-pgsql = callPackage ../by-name/sy/syncstorage-rs/package.nix {
9468+
dbBackend = "postgresql";
9469+
};
9470+
94649471
synergyWithoutGUI = synergy.override { withGUI = false; };
94659472

94669473
tabbed = callPackage ../applications/window-managers/tabbed {

0 commit comments

Comments
 (0)