Skip to content

Commit

Permalink
Merge pull request #232439 from ncfavier/fix-syncthing
Browse files Browse the repository at this point in the history
nixos/syncthing: fixup #226088
  • Loading branch information
ncfavier authored May 17, 2023
2 parents a6c09de + 40a2df0 commit 10aa44f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 9 additions & 7 deletions nixos/modules/services/networking/syncthing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ let
deviceID = device.id;
}) 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:
if builtins.isString device then
{ deviceId = cfg.settings.devices.${device}.id; }
Expand Down Expand Up @@ -121,10 +125,9 @@ in {
description = mdDoc ''
The options element contains all other global configuration options
'';
type = types.attrsOf (types.submodule ({ name, ... }: {
type = types.submodule ({ name, ... }: {
freeformType = settingsFormat.type;
options = {

localAnnounceEnabled = mkOption {
type = types.bool;
default = true;
Expand Down Expand Up @@ -176,7 +179,7 @@ in {
'';
};
};
}));
});
};

# device settings
Expand Down Expand Up @@ -344,6 +347,7 @@ in {
]
'';
type = with types; nullOr (submodule {
freeformType = settingsFormat.type;
options = {
type = mkOption {
type = enum [ "external" "simple" "staggered" "trashcan" ];
Expand Down Expand Up @@ -609,9 +613,7 @@ in {
];
};
};
syncthing-init = mkIf (
cfg.settings.devices != {} || cfg.folders != {} || cfg.extraOptions != {}
) {
syncthing-init = mkIf (cfg.settings != {}) {
description = "Syncthing configuration updater";
requisite = [ "syncthing.service" ];
after = [ "syncthing.service" ];
Expand Down
5 changes: 5 additions & 0 deletions nixos/tests/syncthing-init.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ in {
services.syncthing = {
enable = true;
settings = {
options.crashReportingEnabled = false;
devices.testDevice = {
id = testId;
};
folders.testFolder = {
path = "/tmp/test";
devices = [ "testDevice" ];
versioning = {
type = "simple";
params.keep = "10";
};
};
gui.user = "guiUser";
};
Expand Down

0 comments on commit 10aa44f

Please sign in to comment.