home

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

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

systems: migrate syncthing out of profile

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

Diffstat:
Msystems/hosts/wakasu.nix | 8++++----
Msystems/modules/desktop/default.nix | 1+
Asystems/modules/desktop/syncthing.nix | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msystems/modules/profiles/syncthing.nix | 78++----------------------------------------------------------------------------
4 files changed, 102 insertions(+), 80 deletions(-)

diff --git a/systems/hosts/wakasu.nix b/systems/hosts/wakasu.nix @@ -80,6 +80,10 @@ in }; desktop = { wayland.sway.enable = true; + syncthing = { + enable = true; + guiAddress = "${metadata.hosts.wakasu.wireguard.addrs.v4}:8384"; + }; }; }; @@ -87,9 +91,6 @@ in profiles.ssh.enable = true; profiles.home = true; profiles.avahi.enable = true; - profiles.syncthing.enable = true; - - environment.systemPackages = with pkgs; [ docker-client ]; @@ -104,7 +105,6 @@ in endpointPort = endpointPort; endpointPublicKey = endpointPublicKey; }; - syncthing.guiAddress = "${metadata.hosts.wakasu.wireguard.addrs.v4}:8384"; }; } diff --git a/systems/modules/desktop/default.nix b/systems/modules/desktop/default.nix @@ -5,5 +5,6 @@ ./sway.nix ./wayland.nix ./xorg.nix + ./syncthing.nix ]; } diff --git a/systems/modules/desktop/syncthing.nix b/systems/modules/desktop/syncthing.nix @@ -0,0 +1,95 @@ +{ 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/profiles/syncthing.nix b/systems/modules/profiles/syncthing.nix @@ -1,40 +1,6 @@ { config, lib, pkgs, ... }: with lib; -let - unstable = versionOlder config.system.nixos.release "21.05"; - cfg = config.profiles.syncthing; - isCurrentHost = n: v: n != config.networking.hostName; - devices = { - aomi = { - id = "XCR6WWB-OZUDGFB-LQPFW73-MV5SPJK-4IGOMA4-IAXON3I-C6OFETL-TPK5FQS"; - addresses = [ "tcp://aomi.vpn" "tcp://aomi.home" ]; - }; - naruhodo = { - id = "BKZN3FH-KRP4XRN-XFEVCCG-VANAUJN-YFAUS5Q-WUOLQQ7-II7I6PR-NVJZXQT"; - addresses = [ "tcp://naruhodo.vpn" "tcp://naruhodo.home" ]; - # addresses = [ "tcp://192.168.1.2" "tcp://void.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 - wakasu = { - id = "XNCACMA-LMIZPRZ-J6LEMR5-BVI7IVQ-6HWWMUU-QUCA63X-ZE32NOP-QFDDGQM"; - addresses = [ "tcp://wakasu.home" "tcp://wakasu.vpn" ]; - }; - }; - deviceNames = builtins.attrNames (filterAttrs isCurrentHost devices); -in { options = { profiles.syncthing = { @@ -42,47 +8,7 @@ in }; }; 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"; - }; + warnings = [ "The option 'profiles.syncthing' is deprecated, use 'modules.desktop.syncthing' instead" ]; + modules.desktop.syncthing = cfg.enable; }; }