home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit c06f52f3b03fce67f33a2f93577fd5a7ed0146a0
parent 1f4d9ef518dc6fdca5cb8c8049c3be3cff0b9680
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Sun, 21 Aug 2022 11:22:52 +0200

systems/modules: move syncthing from desktop to services

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Msystems/hosts/wakasu.nix | 2++
Msystems/modules/desktop/default.nix | 1-
Dsystems/modules/desktop/syncthing.nix | 95-------------------------------------------------------------------------------
Msystems/modules/services/default.nix | 1+
Asystems/modules/services/syncthing.nix | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 98 insertions(+), 96 deletions(-)

diff --git a/systems/hosts/wakasu.nix b/systems/hosts/wakasu.nix @@ -80,6 +80,8 @@ in }; desktop = { wayland.sway.enable = true; + }; + services = { syncthing = { enable = true; guiAddress = "${metadata.hosts.wakasu.wireguard.addrs.v4}:8384"; diff --git a/systems/modules/desktop/default.nix b/systems/modules/desktop/default.nix @@ -5,6 +5,5 @@ ./sway.nix ./wayland.nix ./xorg.nix - ./syncthing.nix ]; } diff --git a/systems/modules/desktop/syncthing.nix b/systems/modules/desktop/syncthing.nix @@ -1,95 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -let - # unstable = versionOlder config.system.nixos.release "21.05"; - cfg = config.modules.desktop.syncthing; - isCurrentHost = n: v: n != config.networking.hostName; - devices = { - wakasu = { - id = "3P5BRF6-27NH2OX-3ZUI7EZ-BP4KCSE-EF2GMJL-DHUGPP2-OGHIJVO-LAJOMA7"; - addresses = [ "tcp://wakasu.home" "tcp://wakasu.vpn" ]; - }; - aomi = { - id = "XCR6WWB-OZUDGFB-LQPFW73-MV5SPJK-4IGOMA4-IAXON3I-C6OFETL-TPK5FQS"; - addresses = [ "tcp://aomi.vpn" "tcp://aomi.home" ]; - }; - sakhalin = { - id = "4TYYG7V-A67D5SN-HMEJCI7-POOZRLL-RNCIE4U-ZYVGTOB-JQ5DOSV-ZCGWUAL"; - addresses = [ "tcp://sakhalin.home" "tcp://sakhalin.vpn" ]; - }; - shikoku = { - id = "KZMMXRR-UINDQTS-H3TV2W7-EIGOUDI-3LW4ZDG-7PRKDFV-MJ5KUTJ-YG5Y5AI"; - addresses = [ "tcp://shikoku.home" "tcp://shikoku.vpn" ]; - }; - okinawa = { - id = "2RWT47Z-UGSH4QO-G4W6XN7-3XY722R-ZKGDN5U-4MDGHMA-6SM26QM-7VCQIAZ"; - addresses = [ "tcp://okinawa.home" "tcp://okinawa.vpn" ]; - }; - # Deprecated - naruhodo = { - id = "BKZN3FH-KRP4XRN-XFEVCCG-VANAUJN-YFAUS5Q-WUOLQQ7-II7I6PR-NVJZXQT"; - addresses = [ "tcp://naruhodo.vpn" "tcp://naruhodo.home" ]; - }; - }; - deviceNames = builtins.attrNames (filterAttrs isCurrentHost devices); -in -{ - options = { - modules.desktop.syncthing = { - enable = mkEnableOption "Enable syncthing profile"; - guiAddress = mkOption { - type = types.str; - default = "127.0.0.1:8384"; - description = '' - The address to serve the web interface at. - ''; - }; - }; - }; - config = mkIf cfg.enable { - 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"; - guiAddress = cfg.guiAddress; - }; - }; -} diff --git a/systems/modules/services/default.nix b/systems/modules/services/default.nix @@ -3,6 +3,7 @@ ./barrier.nix ./govanityurl.nix ./nix-binary-cache.nix + ./syncthing.nix ./wireguard.client.nix ]; } diff --git a/systems/modules/services/syncthing.nix b/systems/modules/services/syncthing.nix @@ -0,0 +1,95 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + # unstable = versionOlder config.system.nixos.release "21.05"; + cfg = config.modules.services.syncthing; + isCurrentHost = n: v: n != config.networking.hostName; + devices = { + wakasu = { + id = "3P5BRF6-27NH2OX-3ZUI7EZ-BP4KCSE-EF2GMJL-DHUGPP2-OGHIJVO-LAJOMA7"; + addresses = [ "tcp://wakasu.home" "tcp://wakasu.vpn" ]; + }; + aomi = { + id = "XCR6WWB-OZUDGFB-LQPFW73-MV5SPJK-4IGOMA4-IAXON3I-C6OFETL-TPK5FQS"; + addresses = [ "tcp://aomi.vpn" "tcp://aomi.home" ]; + }; + sakhalin = { + id = "4TYYG7V-A67D5SN-HMEJCI7-POOZRLL-RNCIE4U-ZYVGTOB-JQ5DOSV-ZCGWUAL"; + addresses = [ "tcp://sakhalin.home" "tcp://sakhalin.vpn" ]; + }; + shikoku = { + id = "KZMMXRR-UINDQTS-H3TV2W7-EIGOUDI-3LW4ZDG-7PRKDFV-MJ5KUTJ-YG5Y5AI"; + addresses = [ "tcp://shikoku.home" "tcp://shikoku.vpn" ]; + }; + okinawa = { + id = "2RWT47Z-UGSH4QO-G4W6XN7-3XY722R-ZKGDN5U-4MDGHMA-6SM26QM-7VCQIAZ"; + addresses = [ "tcp://okinawa.home" "tcp://okinawa.vpn" ]; + }; + # Deprecated + naruhodo = { + id = "BKZN3FH-KRP4XRN-XFEVCCG-VANAUJN-YFAUS5Q-WUOLQQ7-II7I6PR-NVJZXQT"; + addresses = [ "tcp://naruhodo.vpn" "tcp://naruhodo.home" ]; + }; + }; + deviceNames = builtins.attrNames (filterAttrs isCurrentHost devices); +in +{ + options = { + modules.services.syncthing = { + enable = mkEnableOption "Enable syncthing profile"; + guiAddress = mkOption { + type = types.str; + default = "127.0.0.1:8384"; + description = '' + The address to serve the web interface at. + ''; + }; + }; + }; + config = mkIf cfg.enable { + 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"; + guiAddress = cfg.guiAddress; + }; + }; +}