Skip to content

Commit 5fb2afd

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 6f0b0c8 commit 5fb2afd

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
@@ -30,7 +30,13 @@ let
3030
# where the syncserver starts before its database and role exist.
3131
dbService = if dbIsMySQL then "mysql.service" else "postgresql.target";
3232

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

3541
format = pkgs.formats.toml { };
3642
settings = {
@@ -149,7 +155,20 @@ in
149155
{option}`${opt.singleNode.enable}` does this automatically when enabled
150156
'';
151157

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

154173
database.type = lib.mkOption {
155174
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)