Skip to content

Commit b2cc6cd

Browse files
committed
fixup! address comments
1 parent 8af1c5f commit b2cc6cd

4 files changed

Lines changed: 71 additions & 82 deletions

File tree

nixos/doc/manual/release-notes/rl-2511.section.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@
398398

399399
- `prosody` gained a config check option named `services.prosody.checkConfig` which runs `prosodyctl check config` and is turned on by default.
400400

401-
- [](#opt-services.firefox-syncserver.database.type) has been added to allow choosing between MySQL/MariaDB (default) and PostgreSQL as the database backend for the Firefox Sync server.
402-
403401
- Revamp of the ACME certificate acquisition and renewal process to help scale systems with lots (100+) of certificates.
404402

405403
Units and targets have been reshaped to better support more specific dependency propagation and avoid

nixos/doc/manual/release-notes/rl-2605.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ See <https://github.com/NixOS/nixpkgs/issues/481673>.
245245

246246
- IPVLAN interfaces can now be configured through the `networking.ipvlans` option in the networking module.
247247

248+
- [](#opt-services.firefox-syncserver.database.type) has been added to allow choosing between MySQL/MariaDB (default) and PostgreSQL as the database backend for the Firefox Sync server.
249+
248250
- `services.caddy` now supports setting `httpPort` and `httpsPort` and opening them in the firewall via `openFirewall`.
249251

250252
- `boot.initrd.secrets` is now deprecated in favour of `boot.initrd.secretPaths` and `boot.initrd.extraSecretsHook`.

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

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -56,85 +56,74 @@ let
5656
};
5757
configFile = format.generate "syncstorage.toml" (lib.recursiveUpdate settings cfg.settings);
5858

59-
mysqlSetupScript = pkgs.writeShellScript "firefox-syncserver-setup" ''
60-
set -euo pipefail
61-
shopt -s inherit_errexit
62-
63-
schema_configured() {
64-
mysql ${cfg.database.name} -Ne 'SHOW TABLES' | grep -q services
65-
}
66-
67-
update_config() {
68-
mysql ${cfg.database.name} <<"EOF"
69-
BEGIN;
70-
71-
INSERT INTO `services` (`id`, `service`, `pattern`)
72-
VALUES (1, 'sync-1.5', '{node}/1.5/{uid}')
73-
ON DUPLICATE KEY UPDATE service='sync-1.5', pattern='{node}/1.5/{uid}';
74-
INSERT INTO `nodes` (`id`, `service`, `node`, `available`, `current_load`,
75-
`capacity`, `downed`, `backoff`)
76-
VALUES (1, 1, '${cfg.singleNode.url}', ${toString cfg.singleNode.capacity},
77-
0, ${toString cfg.singleNode.capacity}, 0, 0)
78-
ON DUPLICATE KEY UPDATE node = '${cfg.singleNode.url}', capacity=${toString cfg.singleNode.capacity};
79-
80-
COMMIT;
81-
EOF
82-
}
83-
84-
85-
for (( try = 0; try < 60; try++ )); do
86-
if ! schema_configured; then
87-
sleep 2
88-
else
89-
update_config
90-
exit 0
91-
fi
92-
done
93-
94-
echo "Single-node setup failed"
95-
exit 1
96-
'';
97-
98-
postgresqlSetupScript = pkgs.writeShellScript "firefox-syncserver-setup" ''
99-
set -euo pipefail
100-
shopt -s inherit_errexit
101-
102-
schema_configured() {
103-
psql -d ${cfg.database.name} -tAc "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'services')" | grep -q t
104-
}
105-
106-
update_config() {
107-
psql -d ${cfg.database.name} <<'EOF'
108-
BEGIN;
109-
110-
INSERT INTO services (id, service, pattern)
111-
VALUES (1, 'sync-1.5', '{node}/1.5/{uid}')
112-
ON CONFLICT (id) DO UPDATE SET service = 'sync-1.5', pattern = '{node}/1.5/{uid}';
113-
INSERT INTO nodes (id, service, node, available, current_load,
114-
capacity, downed, backoff)
115-
VALUES (1, 1, '${cfg.singleNode.url}', ${toString cfg.singleNode.capacity},
116-
0, ${toString cfg.singleNode.capacity}, 0, 0)
117-
ON CONFLICT (id) DO UPDATE SET node = '${cfg.singleNode.url}', capacity = ${toString cfg.singleNode.capacity};
118-
119-
COMMIT;
120-
EOF
121-
}
122-
59+
setupScript =
60+
let
61+
dbSpecific =
62+
if dbIsMySQL then
63+
{
64+
listTables = "mysql ${cfg.database.name} -Ne 'SHOW TABLES'";
65+
execSql = "mysql ${cfg.database.name}";
66+
upsertSql = ''
67+
BEGIN;
68+
69+
INSERT INTO `services` (`id`, `service`, `pattern`)
70+
VALUES (1, 'sync-1.5', '{node}/1.5/{uid}')
71+
ON DUPLICATE KEY UPDATE service='sync-1.5', pattern='{node}/1.5/{uid}';
72+
INSERT INTO `nodes` (`id`, `service`, `node`, `available`, `current_load`,
73+
`capacity`, `downed`, `backoff`)
74+
VALUES (1, 1, '${cfg.singleNode.url}', ${toString cfg.singleNode.capacity},
75+
0, ${toString cfg.singleNode.capacity}, 0, 0)
76+
ON DUPLICATE KEY UPDATE node = '${cfg.singleNode.url}', capacity=${toString cfg.singleNode.capacity};
77+
78+
COMMIT;
79+
'';
80+
}
81+
else
82+
{
83+
listTables = "psql -d ${cfg.database.name} -tAc \"SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'services')\"";
84+
execSql = "psql -d ${cfg.database.name}";
85+
upsertSql = ''
86+
BEGIN;
87+
88+
INSERT INTO services (id, service, pattern)
89+
VALUES (1, 'sync-1.5', '{node}/1.5/{uid}')
90+
ON CONFLICT (id) DO UPDATE SET service = 'sync-1.5', pattern = '{node}/1.5/{uid}';
91+
INSERT INTO nodes (id, service, node, available, current_load,
92+
capacity, downed, backoff)
93+
VALUES (1, 1, '${cfg.singleNode.url}', ${toString cfg.singleNode.capacity},
94+
0, ${toString cfg.singleNode.capacity}, 0, 0)
95+
ON CONFLICT (id) DO UPDATE SET node = '${cfg.singleNode.url}', capacity = ${toString cfg.singleNode.capacity};
96+
97+
COMMIT;
98+
'';
99+
};
100+
in
101+
pkgs.writeShellScript "firefox-syncserver-setup" ''
102+
set -euo pipefail
103+
shopt -s inherit_errexit
123104
124-
for (( try = 0; try < 60; try++ )); do
125-
if ! schema_configured; then
126-
sleep 2
127-
else
128-
update_config
129-
exit 0
130-
fi
131-
done
105+
schema_configured() {
106+
${dbSpecific.listTables} | grep -q services
107+
}
132108
133-
echo "Single-node setup failed"
134-
exit 1
135-
'';
109+
update_config() {
110+
${dbSpecific.execSql} <<'EOF'
111+
${dbSpecific.upsertSql}
112+
EOF
113+
}
136114
137-
setupScript = if dbIsMySQL then mysqlSetupScript else postgresqlSetupScript;
115+
for (( try = 0; try < 60; try++ )); do
116+
if ! schema_configured; then
117+
sleep 2
118+
else
119+
update_config
120+
exit 0
121+
fi
122+
done
123+
124+
echo "Single-node setup failed"
125+
exit 1
126+
'';
138127
in
139128

140129
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ in
3333

3434
rustPlatform.buildRustPackage (finalAttrs: {
3535
pname = "syncstorage-rs";
36-
version = "0.21.1-unstable-2026-02-24";
36+
version = "0.22.2";
3737

3838
src = fetchFromGitHub {
3939
owner = "mozilla-services";
4040
repo = "syncstorage-rs";
41-
rev = "50a739b58dc9ec81995f86e71d992aa14ccc450e";
42-
hash = "sha256-idq0RGdwoV6GVuq36IVVVCFbyMTe8i/EpVWE59D/dhM=";
41+
rev = "refs/tags/${finalAttrs.version}";
42+
hash = "sha256-hEDa9hk00QvMY86zrtTq3+UOmbNehDb7Ya8St9u6IuA=";
4343
};
4444

4545
nativeBuildInputs = [
@@ -77,7 +77,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
7777
--prefix PATH : ${lib.makeBinPath [ pyFxADeps ]}
7878
'';
7979

80-
cargoHash = "sha256-80EztkSX+SnmqsRWIXbChUB8AeV1Tp9WXoWNbDY8rUE=";
80+
cargoHash = "sha256-lTjvRTenmxYAYS5HB32x19DLkdd09jeWOhUbzt7TQ4Y=";
8181

8282
# almost all tests need a DB to test against
8383
doCheck = false;

0 commit comments

Comments
 (0)