From 804ca52ae868aa88df7c64f261e463a0a62fd407 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 27 Sep 2024 18:07:05 +0200 Subject: [PATCH] syncthing go brrr --- justfile | 4 ++-- users/pbsds/syncthing.nix | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/justfile b/justfile index f1a8428..f6ed277 100644 --- a/justfile +++ b/justfile @@ -59,8 +59,8 @@ push hostname=`just _a_host` cmd=`gum choose test switch boot --header "Select m inspect: nix run -- nixpkgs#nix-inspect -p . -inspect-config host=`just _a_host`: - nix run -- nixpkgs#nix-inspect -e '(builtins.getFlake "'"$PWD"'").nixosConfigurations.{{host}}.config' +inspect-config host=`just _a_host` prefix="": + nix run -- nixpkgs#nix-inspect -e '(builtins.getFlake "'"$PWD"'").nixosConfigurations.{{host}}.config{{ if prefix == "" { "" } else { "." + prefix } }}' @_a_host: hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \ diff --git a/users/pbsds/syncthing.nix b/users/pbsds/syncthing.nix index 2f0d466..5b6f71c 100644 --- a/users/pbsds/syncthing.nix +++ b/users/pbsds/syncthing.nix @@ -2,12 +2,6 @@ # todo: portable service and system-manager -let - inherit (config.services.syncthing) - dataDir - ; -in - { environment.systemPackages = lib.mkIf config.services.syncthing.enable [ @@ -38,15 +32,25 @@ in # TODO: somehow don't create ~/Sync # nix run -- nixpkgs#syncthing generate --config="$HOME"/syncthing/.config/syncthing - devices."bjarte".id = "C7QQYJU-PMJDP2Z-CKTAV4A-V6IFEG5-YFBGCNU-PJPCZFC-QSXKZY3-NC5WRAL"; - devices."rocm".id = "UFW6V4E-LMEDTYR-23BU6BP-2HEMWYB-2ARCJ4X-T67WHZX-BNCCHZ4-5GPSZQV"; - devices."sopp".id = "ZQJEWAX-GALDJDO-FBOE5ON-M5XKXNT-PRZD3CY-S7L3XDR-PR27NYL-RZ6O7QW"; + devices."bjarte".id = "C7QQYJU-PMJDP2Z-CKTAV4A-V6IFEG5-YFBGCNU-PJPCZFC-QSXKZY3-NC5WRAL"; + devices."pjudduzen".id = "JCNX5AC-YMXJZBP-5LQRLAL-BGTSXKK-X6AJPXL-IXDWJGW-IHSBTPT-AFXKFAK"; + devices."rocm".id = "UFW6V4E-LMEDTYR-23BU6BP-2HEMWYB-2ARCJ4X-T67WHZX-BNCCHZ4-5GPSZQV"; + devices."sopp".id = "ZQJEWAX-GALDJDO-FBOE5ON-M5XKXNT-PRZD3CY-S7L3XDR-PR27NYL-RZ6O7QW"; /* devices."sopp".autoAcceptFolders = true; # TODO */ - folders."ntnu" = { - path = "${dataDir}/ntnu"; - devices = [ "bjarte" "sopp" "rocm" ]; - /* ignorePerms = false; # `false` means sync file permissions */ + folders = lib.flip lib.pipe [ + (lib.mapAttrs (name: attrs: { path = lib.mkDefault "${config.services.syncthing.dataDir}/${name}"; } // attrs )) + (lib.mapAttrsToList (name: attrs: lib.mkIf (builtins.elem config.networking.hostName (attrs.devices or [])) { ${name} = attrs; } )) + lib.mkMerge + ] { + /* "ntnu".ignorePerms = false; # `false` means sync file permissions */ + "DCIM".devices = [ "bjarte" "sopp" "rocm" "pjudduzen" ]; + "ntnu".devices = [ "bjarte" "sopp" "rocm" ]; + "pjudduzen-clover".devices = [ "pjudduzen" "sopp" ]; + "pjudduzen-movies".devices = [ "pjudduzen" "sopp" ]; + "pjudduzen-music".devices = [ "pjudduzen" "sopp" ]; + "pjudduzen-pictures".devices = [ "pjudduzen" "sopp" ]; + "pjudduzen-snapchat".devices = [ "pjudduzen" "sopp" ]; }; };