Merge pull request #232439 from ncfavier/fix-syncthing

nixos/syncthing: fixup #226088
This commit is contained in:
Naïm Favier 2023-05-17 17:03:14 +02:00 committed by GitHub
commit 10aa44f1d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -13,7 +13,11 @@ let
deviceID = device.id; deviceID = device.id;
}) cfg.settings.devices; }) cfg.settings.devices;
folders = mapAttrsToList (_: folder: folder // { folders = mapAttrsToList (_: folder: folder //
throwIf (folder?rescanInterval || folder?watch || folder?watchDelay) ''
The options services.syncthing.settings.folders.<name>.{rescanInterval,watch,watchDelay}
were removed. Please use, respectively, {rescanIntervalS,fsWatcherEnabled,fsWatcherDelayS} instead.
'' {
devices = map (device: devices = map (device:
if builtins.isString device then if builtins.isString device then
{ deviceId = cfg.settings.devices.${device}.id; } { deviceId = cfg.settings.devices.${device}.id; }
@ -121,10 +125,9 @@ in {
description = mdDoc '' description = mdDoc ''
The options element contains all other global configuration options The options element contains all other global configuration options
''; '';
type = types.attrsOf (types.submodule ({ name, ... }: { type = types.submodule ({ name, ... }: {
freeformType = settingsFormat.type; freeformType = settingsFormat.type;
options = { options = {
localAnnounceEnabled = mkOption { localAnnounceEnabled = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
@ -176,7 +179,7 @@ in {
''; '';
}; };
}; };
})); });
}; };
# device settings # device settings
@ -344,6 +347,7 @@ in {
] ]
''; '';
type = with types; nullOr (submodule { type = with types; nullOr (submodule {
freeformType = settingsFormat.type;
options = { options = {
type = mkOption { type = mkOption {
type = enum [ "external" "simple" "staggered" "trashcan" ]; type = enum [ "external" "simple" "staggered" "trashcan" ];
@ -609,9 +613,7 @@ in {
]; ];
}; };
}; };
syncthing-init = mkIf ( syncthing-init = mkIf (cfg.settings != {}) {
cfg.settings.devices != {} || cfg.folders != {} || cfg.extraOptions != {}
) {
description = "Syncthing configuration updater"; description = "Syncthing configuration updater";
requisite = [ "syncthing.service" ]; requisite = [ "syncthing.service" ];
after = [ "syncthing.service" ]; after = [ "syncthing.service" ];

View file

@ -10,12 +10,17 @@ in {
services.syncthing = { services.syncthing = {
enable = true; enable = true;
settings = { settings = {
options.crashReportingEnabled = false;
devices.testDevice = { devices.testDevice = {
id = testId; id = testId;
}; };
folders.testFolder = { folders.testFolder = {
path = "/tmp/test"; path = "/tmp/test";
devices = [ "testDevice" ]; devices = [ "testDevice" ];
versioning = {
type = "simple";
params.keep = "10";
};
}; };
gui.user = "guiUser"; gui.user = "guiUser";
}; };