diff --git a/homeManagerModules/desktop/default.nix b/homeManagerModules/desktop/default.nix index 4a8d2e27..81ba7a4f 100644 --- a/homeManagerModules/desktop/default.nix +++ b/homeManagerModules/desktop/default.nix @@ -43,8 +43,8 @@ "file://${config.home.homeDirectory}/src" ] ++ lib.optional ( - osConfig.ar.services.syncthing.enable - && (osConfig.ar.services.syncthing.user == config.home.username) + osConfig.ar.users.aly.syncthing.enable + && (config.home.username == "aly") ) "file://${config.home.homeDirectory}/sync"; xdg = { diff --git a/hosts/fallarbor/default.nix b/hosts/fallarbor/default.nix index 6f41a88b..fb820e72 100644 --- a/hosts/fallarbor/default.nix +++ b/hosts/fallarbor/default.nix @@ -33,19 +33,17 @@ hyprland.enable = true; }; - services = { - flatpak.enable = true; - - syncthing = { - enable = true; - syncMusic = false; - }; - }; + services.flatpak.enable = true; users = { aly = { enable = true; password = "$y$j9T$0p6rc4p5sn0LJ/6XyAGP7.$.wmTafwMMscdW1o8kqqoHJP7U8kF.4WBmzzcPYielR3"; + + syncthing = { + enable = true; + syncMusic = false; + }; }; dustin = { diff --git a/hosts/lavaridge/default.nix b/hosts/lavaridge/default.nix index adb15265..9a54f09a 100644 --- a/hosts/lavaridge/default.nix +++ b/hosts/lavaridge/default.nix @@ -44,11 +44,10 @@ hyprland.enable = true; }; - services.syncthing.enable = true; - users.aly = { enable = true; password = "$y$j9T$NSS7QcEtN4yiigPyofwlI/$nxdgz0lpySa0heDMjGlHe1gX3BWf48jK6Tkfg4xMEs6"; + syncthing.enable = true; }; }; } diff --git a/hosts/mauville/default.nix b/hosts/mauville/default.nix index f7d5478c..ae596318 100644 --- a/hosts/mauville/default.nix +++ b/hosts/mauville/default.nix @@ -122,6 +122,11 @@ in { aly = { enable = true; password = "$y$j9T$SHPShqI2IpRE101Ey2ry/0$0mhW1f9LbVY02ifhJlP9XVImge9HOpf23s9i1JFLIt9"; + + syncthing = { + enable = true; + musicPath = "${mediaDirectory}/Music"; + }; }; dustin = { @@ -129,14 +134,6 @@ in { password = "$y$j9T$3mMCBnUQ.xjuPIbSof7w0.$fPtRGblPRSwRLj7TFqk1nzuNQk2oVlgvb/bE47sghl."; }; }; - - services = { - syncthing = { - enable = true; - syncMusic = true; - musicPath = "${mediaDirectory}/Music"; - }; - }; }; raffauflabs = { diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index 88a83f85..d8dae8df 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -65,11 +65,10 @@ hyprland.enable = true; }; - services.syncthing.enable = true; - users.aly = { enable = true; password = "$y$j9T$TitXX3J690cnK41XciNMg/$APKHM/os6FKd9H9aXGxaHaQ8zP5SenO9EO94VYafl43"; + syncthing.enable = true; }; }; } diff --git a/hosts/rustboro/default.nix b/hosts/rustboro/default.nix index c2def153..65673154 100644 --- a/hosts/rustboro/default.nix +++ b/hosts/rustboro/default.nix @@ -40,11 +40,10 @@ hyprland.enable = true; }; - services.syncthing.enable = true; - users.aly = { enable = true; password = "$y$j9T$VdtiEyMOegHpcUwgmCVFD0$K8Ne6.zk//VJNq2zxVQ0xE0Wg3LohvAQd3Xm9aXdM15"; + syncthing.enable = true; }; }; } diff --git a/nixosModules/options.nix b/nixosModules/options.nix index 1397d66c..d7da7011 100644 --- a/nixosModules/options.nix +++ b/nixosModules/options.nix @@ -44,28 +44,6 @@ services = { flatpak.enable = lib.mkEnableOption "Flatpak support with GUI."; - - syncthing = { - enable = lib.mkEnableOption "Syncthing sync service."; - - user = lib.mkOption { - description = "Specify user Syncthing runs as."; - default = "aly"; - type = lib.types.str; - }; - - syncMusic = lib.mkOption { - description = "Whether to sync music folder."; - default = config.ar.services.syncthing.enable; - type = lib.types.bool; - }; - - musicPath = lib.mkOption { - description = "Whether to sync music folder."; - default = "/home/${config.ar.services.syncthing.user}/music"; - type = lib.types.str; - }; - }; }; }; } diff --git a/nixosModules/services/default.nix b/nixosModules/services/default.nix index aff2fdc2..2c7f609f 100644 --- a/nixosModules/services/default.nix +++ b/nixosModules/services/default.nix @@ -6,6 +6,5 @@ }: { imports = [ ./flatpak - ./syncthing ]; } diff --git a/nixosModules/services/syncthing/default.nix b/nixosModules/services/syncthing/default.nix deleted file mode 100644 index 47a1a5f9..00000000 --- a/nixosModules/services/syncthing/default.nix +++ /dev/null @@ -1,91 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: { - config = let - cfg = config.ar.services.syncthing; - in - lib.mkIf cfg.enable { - age.secrets = { - syncthingCert.file = ../../../secrets/syncthing + "/${config.networking.hostName}/cert.age"; - syncthingKey.file = ../../../secrets/syncthing + "/${config.networking.hostName}/key.age"; - }; - - systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; - - services.syncthing = { - enable = true; - cert = config.age.secrets.syncthingCert.path; - dataDir = "/home/${cfg.user}"; - key = config.age.secrets.syncthingKey.path; - openDefaultPorts = true; - user = cfg.user; - settings = { - options = { - localAnnounceEnabled = true; - relaysEnabled = true; - urAccepted = -1; - }; - - devices = { - "brawly" = {id = "BBIBWMR-CN4CFC4-2XMPLII-XFWXBT5-EPCZCAF-JOWAX5J-DHIGNM4-O3XQ4Q3";}; # Pixel 6a - "fallarbor" = {id = "P4URLH4-YWLMO6J-W62ET7H-TQAO3Y6-T2FAYOY-C2VTI65-VQXHVGG-NQ76PAZ";}; # Framework 13 Intel 11th gen - "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 = "TMMSCVA-MDJTDPC-PC47NUA-2VPLAIB-6S6MEU7-KALIGUJ-AWDUOUU-XD73MAY";}; # 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 = "ECTD3LW-YZTJIXX-HLQYXT7-UGZSGST-3DDKF72-DJPMDHE-SUYDWIT-ASTKTAE";}; # Yoga 9i - "rustboro" = {id = "7CXGPQN-7DYDYJN-DKELOR3-RD4HZUW-SSUDGLZ-WVXYFUT-DPT2MGD-6PO5BQF";}; # Thinkpad t440p - "wallace" = {id = "X55NQL2-H3TEJ5U-EXZPBKQ-LI6BMB4-W2ULDIJ-YNIHJHB-4ISCOJB-UHNLYAX";}; # Samsung a35 - "winona" = {id = "IGAW5SS-WY2QN6J-5TF74YZ-6XPNPTC-RCH3HIT-ZZQKCAI-6L54IS2-SNRIMA2";}; # Pixel Tablet - }; - - folders = - { - "sync" = { - id = "default"; - path = "/home/${cfg.user}/sync"; - devices = ["brawly" "fallarbor" "gsgmba" "iphone12" "lavaridge" "mauville" "petalburg" "rustboro" "mossdeep" "wallace" "winona"]; - versioning = { - type = "staggered"; - params = { - cleanInterval = "3600"; - maxAge = "1"; - }; - }; - }; - - "camera" = { - id = "fcsgh-dlxys"; - path = "/home/${cfg.user}/pics/camera"; - devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"]; - versioning = { - params.cleanoutDays = "5"; - type = "trashcan"; - }; - }; - - "screenshots" = { - id = "screenshots"; - path = "/home/${cfg.user}/pics/screenshots"; - devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"]; - versioning = { - params.cleanoutDays = "5"; - type = "trashcan"; - }; - }; - } - // lib.attrsets.optionalAttrs (config.ar.services.syncthing.syncMusic) { - "music" = { - id = "6nzmu-z9der"; - path = config.ar.services.syncthing.musicPath; - devices = ["lavaridge" "mauville" "petalburg" "rustboro" "wallace"]; - }; - }; - }; - }; - }; -} diff --git a/userModules/aly/default.nix b/userModules/aly/default.nix index 8f0bd27d..af4b4be4 100644 --- a/userModules/aly/default.nix +++ b/userModules/aly/default.nix @@ -6,6 +6,8 @@ self, ... }: { + imports = [./syncthing.nix]; + config = lib.mkIf config.ar.users.aly.enable { home-manager.users.aly = lib.attrsets.optionalAttrs diff --git a/userModules/aly/syncthing.nix b/userModules/aly/syncthing.nix new file mode 100644 index 00000000..7a3059a9 --- /dev/null +++ b/userModules/aly/syncthing.nix @@ -0,0 +1,90 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.ar.users.aly.syncthing; +in { + config = lib.mkIf cfg.enable { + age.secrets = { + syncthingCert.file = ../../secrets/syncthing + "/${config.networking.hostName}/cert.age"; + syncthingKey.file = ../../secrets/syncthing + "/${config.networking.hostName}/key.age"; + }; + + systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; + + services.syncthing = { + enable = true; + cert = config.age.secrets.syncthingCert.path; + dataDir = "/home/aly"; + key = config.age.secrets.syncthingKey.path; + openDefaultPorts = true; + user = "aly"; + settings = { + options = { + localAnnounceEnabled = true; + relaysEnabled = true; + urAccepted = -1; + }; + + devices = { + "brawly" = {id = "BBIBWMR-CN4CFC4-2XMPLII-XFWXBT5-EPCZCAF-JOWAX5J-DHIGNM4-O3XQ4Q3";}; # Pixel 6a + "fallarbor" = {id = "P4URLH4-YWLMO6J-W62ET7H-TQAO3Y6-T2FAYOY-C2VTI65-VQXHVGG-NQ76PAZ";}; # Framework 13 Intel 11th gen + "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 = "TMMSCVA-MDJTDPC-PC47NUA-2VPLAIB-6S6MEU7-KALIGUJ-AWDUOUU-XD73MAY";}; # 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 = "ECTD3LW-YZTJIXX-HLQYXT7-UGZSGST-3DDKF72-DJPMDHE-SUYDWIT-ASTKTAE";}; # Yoga 9i + "rustboro" = {id = "7CXGPQN-7DYDYJN-DKELOR3-RD4HZUW-SSUDGLZ-WVXYFUT-DPT2MGD-6PO5BQF";}; # Thinkpad t440p + "wallace" = {id = "X55NQL2-H3TEJ5U-EXZPBKQ-LI6BMB4-W2ULDIJ-YNIHJHB-4ISCOJB-UHNLYAX";}; # Samsung a35 + "winona" = {id = "IGAW5SS-WY2QN6J-5TF74YZ-6XPNPTC-RCH3HIT-ZZQKCAI-6L54IS2-SNRIMA2";}; # Pixel Tablet + }; + + folders = + { + "sync" = { + id = "default"; + path = "/home/aly/sync"; + devices = ["brawly" "fallarbor" "gsgmba" "iphone12" "lavaridge" "mauville" "petalburg" "rustboro" "mossdeep" "wallace" "winona"]; + versioning = { + type = "staggered"; + params = { + cleanInterval = "3600"; + maxAge = "1"; + }; + }; + }; + + "camera" = { + id = "fcsgh-dlxys"; + path = "/home/aly/pics/camera"; + devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"]; + versioning = { + params.cleanoutDays = "5"; + type = "trashcan"; + }; + }; + + "screenshots" = { + id = "screenshots"; + path = "/home/aly/pics/screenshots"; + devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"]; + versioning = { + params.cleanoutDays = "5"; + type = "trashcan"; + }; + }; + } + // lib.attrsets.optionalAttrs (config.ar.users.aly.syncthing.syncMusic) { + "music" = { + id = "6nzmu-z9der"; + path = config.ar.users.aly.syncthing.musicPath; + devices = ["lavaridge" "mauville" "petalburg" "rustboro" "wallace"]; + }; + }; + }; + }; + }; +} diff --git a/userModules/options.nix b/userModules/options.nix index 9af90273..5055700b 100644 --- a/userModules/options.nix +++ b/userModules/options.nix @@ -35,7 +35,26 @@ ]; }; - aly = mkUser "aly"; + aly = + mkUser "aly" + // { + syncthing = { + enable = lib.mkEnableOption "Syncthing sync service."; + + syncMusic = lib.mkOption { + description = "Whether to sync music folder."; + default = config.ar.users.aly.syncthing.enable; + type = lib.types.bool; + }; + + musicPath = lib.mkOption { + description = "Whether to sync music folder."; + default = "/home/aly/music"; + type = lib.types.str; + }; + }; + }; + dustin = mkUser "dustin"; morgan = mkUser "morgan"; };