Commit 83cae39c9939
Changed files (4)
lib/default.nix
@@ -35,6 +35,7 @@
mkHost =
{ hostname
, desktop ? null
+ , syncthingFolders ? [ ]
, system ? "x86_64-linux"
, pkgsInput ? inputs.nixpkgs
, homeInput ? inputs.home-manager
@@ -49,6 +50,7 @@
stateVersion
hostname
desktop
+ # syncthingFolders
system
;
};
systems/common/services/syncthing.nix
@@ -0,0 +1,64 @@
+{ config
+, lib
+, pkgs
+, outputs
+, ...
+}:
+let
+ isCurrentHost = n: v: n != config.networking.hostName;
+ # Folders list
+ folders = [
+ # TODO maybe deprecate for documents
+ { label = "sync"; id = "7dshg-r8zr6"; }
+ { label = "documents"; id = "oftdb-t5anv"; }
+ { label = "org"; id = "sjpsr-xfwdu"; }
+ { label = "screenshots"; id = "prpsz-azlz9"; }
+ { label = "wallpapers"; id = "wpiah-ydwwx"; }
+ { label = "photos"; id = "uetya-ypa3d"; }
+ { label = "music"; id = "kcyrf-mugzt"; }
+ ];
+ deviceHasFolder = folder: n: v: lib.lists.any (s: s == folder) (if builtins.hasAttr "syncthingFolders" v then v.syncthingFolders else [ ]);
+ devicesForFolder = folder: lib.attrsets.filterAttrs (deviceHasFolder folder) outputs.nixosConfigurations;
+ # outputs.nixosConfigurations.$.syncthingFolders will contains the folders for a host
+
+ # non-nixos syncthing machines
+ extras = [
+ # NAS
+ {
+ name = "aion";
+ id = "YORNSGU-UC4IAG5-IWJCD7T-MVPIU7O-AYM36UK-LEHF7AP-CBC4L6C-ZWKUYQF";
+ addresses = [ "tcp://aion.home" "tcp://aion.vpn" "tcp://aion.sbr.pm" ];
+ folders = [ "org" "documents" "sync" "screenshots" "wallpapers" "photos" "videos" ];
+ }
+ # Macbook
+ {
+ name = "honshu";
+ id = "RGIR34D-3SH3GZK-CYPNNFI-5M5I2K4-HVTUS56-72GJTLH-SDMOY4I-I7AURQR";
+ addresses = [ "tcp://honshu.home" "tcp://honshu.sbr.pm" ];
+ folders = [ ];
+ }
+ # Windows Gaming machine
+ {
+ name = "okinawa";
+ id = "2RWT47Z-UGSH4QO-G4W6XN7-3XY722R-ZKGDN5U-4MDGHMA-6SM26QM-7VCQIAZ";
+ addresses = [ "tcp://okinawa.home" "tcp://okinawa.vpn" "tcp://okinawa.sbr.pm" ];
+ folder = [ ];
+ }
+ # iPhone
+ {
+ name = "hokkaido";
+ id = "XD4XYNZ-DT3PJEY-UJYBHWX-6OQPPUI-HTW752L-FYTX3TW-GVHDTKW-PT336QV";
+ folders = [ "org" "music" "documents" "sync" ];
+ }
+ ];
+in
+{
+ services.syncthing = {
+ enable = true;
+ user = "vincent";
+ dataDir = "/home/vincent/.syncthing";
+ configDir = "/home/vincent/.syncthing";
+ # guiAddress = cfg.guiAddress;
+ settings = { };
+ };
+}
systems/kyushu/extra.nix
@@ -7,6 +7,7 @@
../common/programs/git.nix
../common/programs/tmux.nix
../common/services/networkmanager.nix
+ ../common/services/syncthing.nix
];
}
flake.nix
@@ -77,7 +77,9 @@
kyushu = libx.mkHost {
hostname = "kyushu";
desktop = "sway";
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
+
# sakhalin = libx.mkHost {
# hostname = "sakhalin";
# pkgsInput = inputs.nixpkgs-24_11;
@@ -90,6 +92,7 @@
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-9th-gen
./systems/hosts/wakasu.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
aomi = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
@@ -98,6 +101,7 @@
inputs.nixos-hardware.nixosModules.common-pc-laptop-ssd
./systems/hosts/aomi.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
# Servers (stable)
shikoku = inputs.nixpkgs-24_11.lib.nixosSystem {
@@ -105,6 +109,7 @@
modules = commonModules ++ stableModules ++ [
./systems/hosts/shikoku.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
sakhalin = inputs.nixpkgs-24_11.lib.nixosSystem {
system = "x86_64-linux";
@@ -112,6 +117,7 @@
inputs.nixos-hardware.nixosModules.common-pc-ssd
./systems/hosts/sakhalin.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
kerkouane = inputs.nixpkgs-24_11.lib.nixosSystem {
system = "x86_64-linux";
@@ -119,6 +125,7 @@
./systems/modules/services/govanityurl.nix
./systems/hosts/kerkouane.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
# carthage = inputs.nixpkgs-24_11.lib.nixosSystem {
# system = "aarch64-linux";
@@ -133,6 +140,7 @@
modules = commonModules ++ stableModules ++ [
./systems/hosts/athena.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
# demeter
demeter = inputs.nixpkgs-24_11.lib.nixosSystem {
@@ -140,6 +148,7 @@
modules = commonModules ++ stableModules ++ [
./systems/hosts/demeter.nix
];
+ syncthingFolders = [ "org" "documents" "sync" "screenshots" "wallpapers" ];
};
};