From 4a2ded993c0accb7588867bdf481fa1debcfb5d6 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 26 Apr 2024 22:38:29 -0400 Subject: [PATCH] moved syncthing to alyraffauf.services --- hosts/lavaridge/default.nix | 3 + hosts/mauville/default.nix | 5 ++ hosts/mossdeep/default.nix | 1 + hosts/petalburg/default.nix | 3 + hosts/rustboro/default.nix | 3 + nixosModules/services/default.nix | 2 +- nixosModules/services/syncthing/default.nix | 57 +++++++++++++++++++ nixosModules/services/syncthing/syncMusic.nix | 33 +++++++++++ nixosModules/user/aly/default.nix | 47 --------------- 9 files changed, 106 insertions(+), 48 deletions(-) create mode 100644 nixosModules/services/syncthing/default.nix create mode 100644 nixosModules/services/syncthing/syncMusic.nix diff --git a/hosts/lavaridge/default.nix b/hosts/lavaridge/default.nix index 9c05fe31..57b6feaa 100644 --- a/hosts/lavaridge/default.nix +++ b/hosts/lavaridge/default.nix @@ -45,6 +45,9 @@ podman.enable = true; virt-manager.enable = true; }; + services = { + syncthing.enable = true; + }; }; users.users.aly.hashedPassword = "$y$j9T$O9NgTk6iRfh3mxiRDvfdm1$BjvsAKYEMB3C28652FF15cj/i.3TgQAObQvR0rN1E6C"; diff --git a/hosts/mauville/default.nix b/hosts/mauville/default.nix index 54a156e3..99b86f69 100644 --- a/hosts/mauville/default.nix +++ b/hosts/mauville/default.nix @@ -53,6 +53,11 @@ in { gpu = ""; # rocm is broken on nixos unstable listenAddress = "0.0.0.0:11434"; }; + syncthing = { + enable = true; + syncMusic = true; + syncMusicPath = "${mediaDirectory}/Music"; + }; }; system = { plymouth.enable = true; diff --git a/hosts/mossdeep/default.nix b/hosts/mossdeep/default.nix index 34d01622..e5150e86 100644 --- a/hosts/mossdeep/default.nix +++ b/hosts/mossdeep/default.nix @@ -45,6 +45,7 @@ }; services = { flatpak.enable = true; + syncthing.enable = true; }; }; diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index d5c382b0..938fb43a 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -92,6 +92,9 @@ in { apps = { steam.enable = true; }; + services = { + syncthing.enable = true; + }; }; users.users.aly.hashedPassword = "$y$j9T$Ug0ZLHQQuRciFJDgOI6r00$eHc.KyQY0oU4k0LKRiZiGWJ19jkKNWHpOoyCJbtJif8"; diff --git a/hosts/rustboro/default.nix b/hosts/rustboro/default.nix index c23466dd..94f59baa 100644 --- a/hosts/rustboro/default.nix +++ b/hosts/rustboro/default.nix @@ -67,6 +67,9 @@ apps = { steam.enable = true; }; + services = { + syncthing.enable = true; + }; }; users.users.aly.hashedPassword = "$y$j9T$VdtiEyMOegHpcUwgmCVFD0$K8Ne6.zk//VJNq2zxVQ0xE0Wg3LohvAQd3Xm9aXdM15"; diff --git a/nixosModules/services/default.nix b/nixosModules/services/default.nix index 9d915266..5c74205b 100644 --- a/nixosModules/services/default.nix +++ b/nixosModules/services/default.nix @@ -4,5 +4,5 @@ config, ... }: { - imports = [./binaryCache ./flatpak ./ollama]; + imports = [./binaryCache ./flatpak ./ollama ./syncthing]; } diff --git a/nixosModules/services/syncthing/default.nix b/nixosModules/services/syncthing/default.nix new file mode 100644 index 00000000..b02876fb --- /dev/null +++ b/nixosModules/services/syncthing/default.nix @@ -0,0 +1,57 @@ +{ + pkgs, + lib, + config, + ... +}: { + imports = [./syncMusic.nix]; + + options = { + alyraffauf.services.syncthing.enable = lib.mkEnableOption "Enable Syncthing"; + alyraffauf.services.syncthing.user = lib.mkOption { + description = "Specify user Syncthing runs as."; + default = "aly"; + type = lib.types.str; + }; + }; + + config = lib.mkIf config.alyraffauf.services.syncthing.enable { + services.syncthing = { + enable = true; + openDefaultPorts = true; + user = "${config.alyraffauf.services.syncthing.user}"; + dataDir = "/home/${config.alyraffauf.services.syncthing.user}"; + settings = { + options = { + localAnnounceEnabled = true; + relaysEnabled = true; + urAccepted = -1; + }; + devices = { + "brawly" = {id = "BBIBWMR-CN4CFC4-2XMPLII-XFWXBT5-EPCZCAF-JOWAX5J-DHIGNM4-O3XQ4Q3";}; # Pixel 6a + "gsgmba" = {id = "V2YCZSL-XY7H72L-FGJFWP2-JNYX72O-OJ5V2HY-V4SSSJM-77A7E3Z-7EJFAAV";}; # Work Macbook Air + "iphone12" = {id = "SBQNUXS-H4XDJ3E-RBHJPT5-45WDJJA-2U43M4P-23XGUJ7-E3CNNKZ-BXSGIA3";}; # iPhone 12 Pro Max + "lavaridge" = {id = "6ZHSHTQ-HO7NLK5-JVKGTAN-H7W7KXS-QB5FN2X-CEDETRE-7E6LDHE-U5FYLAS";}; # Framework 13 AMD + "mauville" = {id = "52MTCMC-PKEWSAU-HADMTZU-DY5EKFO-B323P7V-OBXLNTQ-EJY7F7Y-EUWFBQX";}; # Desktop/Homelab + "mossdeep" = {id = "XRIGHMT-54OGBWP-UAAGAJS-LGTRHA2-EMKOMEB-EJEWKZN-GJFK6FO-3O6KQQ4";}; # Steam Deck OLED + "petalburg" = {id = "E7XBKXN-QGEPQGZ-P6PIYXI-3IHWXRD-VJCFLYP-D3M6ACJ-EDZDQ3D-ZLTEBAC";}; # Yoga 9i + "rustboro" = {id = "MUCZMA2-5K3XVT7-CF5W5MG-WZUG3PU-VAX6ZZY-FCTFPEZ-FNRSCNC-A4W5LAR";}; # Thinkpad t440p + "wattson" = {id = "B2EYRQJ-LE2FR2J-D4M35TY-FXVGJ6D-USE7S2T-5V357SV-IQQWEAT-RQBLJQB";}; # Samsung a54 5g + "winona" = {id = "IGAW5SS-WY2QN6J-5TF74YZ-6XPNPTC-RCH3HIT-ZZQKCAI-6L54IS2-SNRIMA2";}; # Pixel Tablet + }; + folders = { + "sync" = { + id = "default"; + path = "/home/${config.alyraffauf.services.syncthing.user}/sync"; + devices = ["brawly" "gsgmba" "iphone12" "lavaridge" "mauville" "petalburg" "rustboro" "mossdeep" "wattson" "winona"]; + }; + "camera" = { + id = "fcsgh-dlxys"; + path = "/home/${config.alyraffauf.services.syncthing.user}/pics/camera"; + devices = ["brawly" "lavaridge" "mauville" "petalburg" "rustboro" "wattson" "winona"]; + }; + }; + }; + }; + }; +} diff --git a/nixosModules/services/syncthing/syncMusic.nix b/nixosModules/services/syncthing/syncMusic.nix new file mode 100644 index 00000000..b5c9d517 --- /dev/null +++ b/nixosModules/services/syncthing/syncMusic.nix @@ -0,0 +1,33 @@ +{ + pkgs, + lib, + config, + ... +}: { + options = { + alyraffauf.services.syncthing.syncMusic = lib.mkOption { + description = "Whether to sync music folder."; + default = true; + type = lib.types.bool; + }; + alyraffauf.services.syncthing.syncMusicPath = lib.mkOption { + description = "Whether to sync music folder."; + default = "/home/${config.alyraffauf.services.syncthing.user}/music"; + type = lib.types.str; + }; + }; + + config = lib.mkIf config.alyraffauf.services.syncthing.syncMusic { + services.syncthing = { + settings = { + folders = { + "music" = { + id = "6nzmu-z9der"; + path = config.alyraffauf.services.syncthing.syncMusicPath; + devices = ["lavaridge" "mauville" "petalburg" "rustboro" "wattson"]; + }; + }; + }; + }; + }; +} diff --git a/nixosModules/user/aly/default.nix b/nixosModules/user/aly/default.nix index 6481ac9b..afa3595d 100644 --- a/nixosModules/user/aly/default.nix +++ b/nixosModules/user/aly/default.nix @@ -10,57 +10,10 @@ }; config = lib.mkIf config.alyraffauf.user.aly.enable { - # Define a user account. Don't forget to set a password with ‘passwd’. users.users.aly = { isNormalUser = true; description = "Aly Raffauf"; extraGroups = ["networkmanager" "wheel" "docker" "libvirtd" "video"]; }; - - services.syncthing = { - enable = true; - openDefaultPorts = true; - user = "aly"; - dataDir = "/home/aly"; - settings = { - options = { - localAnnounceEnabled = true; - relaysEnabled = true; - urAccepted = -1; - }; - devices = { - "brawly" = {id = "BBIBWMR-CN4CFC4-2XMPLII-XFWXBT5-EPCZCAF-JOWAX5J-DHIGNM4-O3XQ4Q3";}; # Pixel 6a - "gsgmba" = {id = "V2YCZSL-XY7H72L-FGJFWP2-JNYX72O-OJ5V2HY-V4SSSJM-77A7E3Z-7EJFAAV";}; # Work Macbook Air - "iphone12" = {id = "SBQNUXS-H4XDJ3E-RBHJPT5-45WDJJA-2U43M4P-23XGUJ7-E3CNNKZ-BXSGIA3";}; # iPhone 12 Pro Max - "lavaridge" = {id = "6ZHSHTQ-HO7NLK5-JVKGTAN-H7W7KXS-QB5FN2X-CEDETRE-7E6LDHE-U5FYLAS";}; # Framework 13 AMD - "mauville" = {id = "52MTCMC-PKEWSAU-HADMTZU-DY5EKFO-B323P7V-OBXLNTQ-EJY7F7Y-EUWFBQX";}; # Desktop/Homelab - "mossdeep" = {id = "XRIGHMT-54OGBWP-UAAGAJS-LGTRHA2-EMKOMEB-EJEWKZN-GJFK6FO-3O6KQQ4";}; # Steam Deck OLED - "petalburg" = {id = "E7XBKXN-QGEPQGZ-P6PIYXI-3IHWXRD-VJCFLYP-D3M6ACJ-EDZDQ3D-ZLTEBAC";}; # Yoga 9i - "rustboro" = {id = "MUCZMA2-5K3XVT7-CF5W5MG-WZUG3PU-VAX6ZZY-FCTFPEZ-FNRSCNC-A4W5LAR";}; # Thinkpad t440p - "wattson" = {id = "B2EYRQJ-LE2FR2J-D4M35TY-FXVGJ6D-USE7S2T-5V357SV-IQQWEAT-RQBLJQB";}; # Samsung a54 5g - "winona" = {id = "IGAW5SS-WY2QN6J-5TF74YZ-6XPNPTC-RCH3HIT-ZZQKCAI-6L54IS2-SNRIMA2";}; # Pixel Tablet - }; - folders = { - "sync" = { - id = "default"; - path = "/home/aly/sync"; - devices = ["brawly" "gsgmba" "iphone12" "lavaridge" "mauville" "petalburg" "rustboro" "mossdeep" "wattson" "winona"]; - }; - "camera" = { - id = "fcsgh-dlxys"; - path = "/home/aly/pics/camera"; - devices = ["brawly" "lavaridge" "mauville" "petalburg" "rustboro" "wattson" "winona"]; - }; - "music" = { - id = "6nzmu-z9der"; - path = - if config.networking.hostName == "mauville" - then "/mnt/Media/Music" - else "/home/aly/music"; - devices = ["lavaridge" "mauville" "petalburg" "rustboro" "wattson"]; - }; - }; - }; - }; }; }