From 5724058e12c6592fa7c885045cfb239d31ad9771 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 22 May 2023 11:57:53 +0200 Subject: [PATCH] nixos/syncthing: fix syncthing-init running by default --- .../modules/services/networking/syncthing.nix | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix index 688f46c4492a9..3b8e2ae30ada8 100644 --- a/nixos/modules/services/networking/syncthing.nix +++ b/nixos/modules/services/networking/syncthing.nix @@ -131,32 +131,32 @@ in { freeformType = settingsFormat.type; options = { localAnnounceEnabled = mkOption { - type = types.bool; - default = true; + type = types.nullOr types.bool; + default = null; description = lib.mdDoc '' Whether to send announcements to the local LAN, also use such announcements to find other devices. ''; }; localAnnouncePort = mkOption { - type = types.int; - default = 21027; + type = types.nullOr types.int; + default = null; description = lib.mdDoc '' The port on which to listen and send IPv4 broadcast announcements to. ''; }; relaysEnabled = mkOption { - type = types.bool; - default = true; + type = types.nullOr types.bool; + default = null; description = lib.mdDoc '' When true, relays will be connected to and potentially used for device to device connections. ''; }; urAccepted = mkOption { - type = types.int; - default = 0; + type = types.nullOr types.int; + default = null; description = lib.mdDoc '' Whether the user has accepted to submit anonymous usage data. The default, 0, mean the user has not made a choice, and Syncthing will ask at some point in the future. @@ -165,16 +165,16 @@ in { }; limitBandwidthInLan = mkOption { - type = types.bool; - default = false; + type = types.nullOr types.bool; + default = null; description = lib.mdDoc '' Whether to apply bandwidth limits to devices in the same broadcast domain as the local device. ''; }; maxFolderConcurrency = mkOption { - type = types.int; - default = 0; + type = types.nullOr types.int; + default = null; description = lib.mdDoc '' This option controls how many folders may concurrently be in I/O-intensive operations such as syncing or scanning. The mechanism is described in detail in a [separate chapter](https://docs.syncthing.net/advanced/option-max-concurrency.html). @@ -615,7 +615,10 @@ in { ]; }; }; - syncthing-init = mkIf (cfg.settings != {}) { + syncthing-init = mkIf ( + # we filter all the null values out to easier compare the two sets + (lib.filterAttrsRecursive (_: v: v != null) cfg.settings) != { devices = {}; folders = {}; options = {}; } + ) { description = "Syncthing configuration updater"; requisite = [ "syncthing.service" ]; after = [ "syncthing.service" ];