commit 26bc2325b6790070f5b435798167d04e06567c43 parent 075f7df9ce7ad592605edb1ea7b67b3d7221810b Author: Vincent Demeester <vincent@sbr.pm> Date: Tue, 28 Sep 2021 19:25:02 +0200 systems: do not fail on syncthing for older nixos the services (and folders) fields are not available before 21.11 (unstable at the time of this commit), so it would fail the build for stable builds (like k8s nodes, …) Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | systems/modules/profiles/syncthing.nix | | | 73 | +++++++++++++++++++++++++++++++++++++++++-------------------------------- |
1 file changed, 41 insertions(+), 32 deletions(-)
diff --git a/systems/modules/profiles/syncthing.nix b/systems/modules/profiles/syncthing.nix @@ -2,6 +2,7 @@ with lib; let + unstable = versionOlder config.system.nixos.release "21.05"; cfg = config.profiles.syncthing; isCurrentHost = n: v: n != config.networking.hostName; devices = { @@ -32,39 +33,47 @@ in }; }; config = mkIf cfg.enable { - services.syncthing = { - enable = true; - user = "vincent"; - dataDir = "/home/vincent/.syncthing"; - configDir = "/home/vincent/.syncthing"; - devices = filterAttrs isCurrentHost devices; - folders = { - "/home/vincent/sync" = { - label = "sync"; - id = "7dshg-r8zr6"; - devices = deviceNames; - }; - "/home/vincent/desktop/org" = { - label = "org"; - id = "sjpsr-xfwdu"; - devices = deviceNames; - }; - "/home/vincent/desktop/documents" = { - label = "documents"; - id = "oftdb-t5anv"; - devices = deviceNames; - }; - "/home/vincent/desktop/pictures/screenshots" = { - label = "screenshots"; - id = "prpsz-azlz9"; - devices = deviceNames; - }; - "/home/vincent/desktop/pictures/wallpapers" = { - label = "wallpapers"; - id = "wpiah-ydwwx"; - devices = deviceNames; + services.syncthing = + if (builtins.hasAttr "devices" config.services.syncthing) + then { + enable = true; + user = "vincent"; + dataDir = "/home/vincent/.syncthing"; + configDir = "/home/vincent/.syncthing"; + devices = filterAttrs isCurrentHost devices; + folders = { + "/home/vincent/sync" = { + label = "sync"; + id = "7dshg-r8zr6"; + devices = deviceNames; + }; + "/home/vincent/desktop/org" = { + label = "org"; + id = "sjpsr-xfwdu"; + devices = deviceNames; + }; + "/home/vincent/desktop/documents" = { + label = "documents"; + id = "oftdb-t5anv"; + devices = deviceNames; + }; + "/home/vincent/desktop/pictures/screenshots" = { + label = "screenshots"; + id = "prpsz-azlz9"; + devices = deviceNames; + }; + "/home/vincent/desktop/pictures/wallpapers" = { + label = "wallpapers"; + id = "wpiah-ydwwx"; + devices = deviceNames; + }; }; + } + else { + enable = true; + user = "vincent"; + dataDir = "/home/vincent/.syncthing"; + configDir = "/home/vincent/.syncthing"; }; - }; }; }