diff --git a/hosts/lilith-lab/default.nix b/hosts/lilith-lab/default.nix index c445397..7f50365 100644 --- a/hosts/lilith-lab/default.nix +++ b/hosts/lilith-lab/default.nix @@ -17,6 +17,11 @@ in }; }; + syncthing = { + enable = true; + dataDir = "/data/sync"; + }; + hardware.nvidia = { package = config.boot.kernelPackages.nvidiaPackages.stable; nvidiaSettings = true; diff --git a/hosts/lilith-pad/default.nix b/hosts/lilith-pad/default.nix index 2869c96..4ccba95 100644 --- a/hosts/lilith-pad/default.nix +++ b/hosts/lilith-pad/default.nix @@ -7,6 +7,7 @@ in audio.enable = true; desktop.enable = true; + syncthing.enable = true; home-manager.users."lilith".desktop.touchSupport = true; nfs.client.enable = true; diff --git a/hosts/lilith-pc/default.nix b/hosts/lilith-pc/default.nix index 21c9c9d..ef2a621 100644 --- a/hosts/lilith-pc/default.nix +++ b/hosts/lilith-pc/default.nix @@ -8,6 +8,7 @@ in audio.enable = true; desktop.enable = true; gaming.enable = true; + syncthing.enable = true; nfs.client.enable = true; auto_styling.enable = true; # ollama.enable = true; diff --git a/system/core/syncthing.nix b/system/core/syncthing.nix index b67907a..63330d9 100644 --- a/system/core/syncthing.nix +++ b/system/core/syncthing.nix @@ -1,64 +1,68 @@ -{ config, ... }: +{ config, lib, ... }: let host = config.networking.hostName; in { + options.syncthing.enable = lib.mkEnableOption "Enables Syncthing"; + options.syncthing.dataDir = lib.mkOption { default = "/home/lilith"; }; - sops.secrets."syncthing/key.pem" = { - sopsFile = ../../hosts/${host}/secrets/default.yaml; - }; - sops.secrets."syncthing/cert.pem" = { - sopsFile = ../../hosts/${host}/secrets/default.yaml; - }; + config = lib.mkIf config.syncthing.enable { + sops.secrets."syncthing/key.pem" = { + sopsFile = ../../hosts/${host}/secrets/default.yaml; + }; + sops.secrets."syncthing/cert.pem" = { + sopsFile = ../../hosts/${host}/secrets/default.yaml; + }; - services.syncthing = { - enable = true; + services.syncthing = { + enable = true; - user = "lilith"; - dataDir = "/home/lilith"; - configDir = "/home/lilith/.config/syncthing"; + user = "lilith"; + dataDir = config.syncthing.dataDir; + configDir = "/home/lilith/.config/syncthing"; - overrideDevices = true; - overrideFolders = true; + overrideDevices = true; + overrideFolders = true; - key = config.sops.secrets."syncthing/key.pem".path; - cert = config.sops.secrets."syncthing/cert.pem".path; + key = config.sops.secrets."syncthing/key.pem".path; + cert = config.sops.secrets."syncthing/cert.pem".path; - settings = { - devices = { - "lilith-phone" = { - id = "N3VHPZJ-DARZYPM-TIBLRAZ-KN6QWYJ-VU6FP2N-INYVJZ3-ZSUD63P-NSXLIQ6"; + settings = { + devices = { + "lilith-phone" = { + id = "N3VHPZJ-DARZYPM-TIBLRAZ-KN6QWYJ-VU6FP2N-INYVJZ3-ZSUD63P-NSXLIQ6"; + }; + "lilith-lab" = { + id = "DW6GTZ3-3JPAHLO-UEB3LBL-AWOX3BT-QPI7ODT-OZ6Q4YR-K3KK22C-5RY3XQZ"; + }; + "lilith-pc" = { + id = "ZXFUFLA-MJJCNE4-SJTGTYD-SEJZUCX-3KIFTL6-LFIWBBU-HD2LX2F-7FQ5VAF"; + }; + "lilith-pad" = { + id = "GQJA6WA-G5YZZSN-4OOQMVE-JPIR22N-VFHPY4O-XMRG37D-DALH4R2-7DCTMQK"; + }; }; - "lilith-lab" = { - id = "DW6GTZ3-3JPAHLO-UEB3LBL-AWOX3BT-QPI7ODT-OZ6Q4YR-K3KK22C-5RY3XQZ"; - }; - "lilith-pc" = { - id = "ZXFUFLA-MJJCNE4-SJTGTYD-SEJZUCX-3KIFTL6-LFIWBBU-HD2LX2F-7FQ5VAF"; - }; - "lilith-pad" = { - id = "GQJA6WA-G5YZZSN-4OOQMVE-JPIR22N-VFHPY4O-XMRG37D-DALH4R2-7DCTMQK"; - }; - }; - folders = { - "sync" = { - id = "rdcj2-mfyb4"; - path = "/home/lilith/sync"; - devices = [ - "lilith-phone" - "lilith-lab" - "lilith-pad" - "lilith-pc" - ]; - }; - "keepass" = { - id = "sdpfs-2beqd"; - path = "/home/lilith/.keepass"; - devices = [ - "lilith-phone" - "lilith-lab" - "lilith-pad" - "lilith-pc" - ]; + folders = { + "sync" = { + id = "rdcj2-mfyb4"; + path = "${config.syncthing.dataDir}/sync"; + devices = [ + "lilith-phone" + "lilith-lab" + "lilith-pad" + "lilith-pc" + ]; + }; + "keepass" = { + id = "sdpfs-2beqd"; + path = "${config.syncthing.dataDir}/.keepass"; + devices = [ + "lilith-phone" + "lilith-lab" + "lilith-pad" + "lilith-pc" + ]; + }; }; }; };