about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorDoron Behar <doron.behar@gmail.com>2023-10-08 12:53:34 +0300
committerGitHub <noreply@github.com>2023-10-08 12:53:34 +0300
commit50a077328a2ca41210154785394d95c396d24e6e (patch)
treee2f1b9feb6e7a6faa70202a6c6436744ce6304c6 /nixos/modules
parentb2c9d3ce0220f8b9a4a533817f38dd789f49a597 (diff)
parent34888cd1d102968fa055db851354fea39e2db146 (diff)
downloadnixlib-50a077328a2ca41210154785394d95c396d24e6e.tar
nixlib-50a077328a2ca41210154785394d95c396d24e6e.tar.gz
nixlib-50a077328a2ca41210154785394d95c396d24e6e.tar.bz2
nixlib-50a077328a2ca41210154785394d95c396d24e6e.tar.lz
nixlib-50a077328a2ca41210154785394d95c396d24e6e.tar.xz
nixlib-50a077328a2ca41210154785394d95c396d24e6e.tar.zst
nixlib-50a077328a2ca41210154785394d95c396d24e6e.zip
Merge pull request #259259 from Lassulus/syncthing_stale
nixos/syncthing: match stale ids by subtracting in jq
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/networking/syncthing.nix14
1 files changed, 7 insertions, 7 deletions
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
index 346b50700c79..d3f6853424c8 100644
--- a/nixos/modules/services/networking/syncthing.nix
+++ b/nixos/modules/services/networking/syncthing.nix
@@ -100,13 +100,13 @@ let
       the Nix configured list of IDs
       */
       + lib.optionalString s.override ''
-        old_conf_${conf_type}_ids="$(curl -X GET ${s.baseAddress} | ${jq} --raw-output '.[].${s.GET_IdAttrName}')"
-        for id in ''${old_conf_${conf_type}_ids}; do
-          if echo ${lib.concatStringsSep " " s.new_conf_IDs} | grep -q $id; then
-            continue
-          else
-            curl -X DELETE ${s.baseAddress}/$id
-          fi
+        stale_${conf_type}_ids="$(curl -X GET ${s.baseAddress} | ${jq} \
+          --argjson new_ids ${lib.escapeShellArg (builtins.toJSON s.new_conf_IDs)} \
+          --raw-output \
+          '[.[].${s.GET_IdAttrName}] - $new_ids | .[]'
+        )"
+        for id in ''${stale_${conf_type}_ids}; do
+          curl -X DELETE ${s.baseAddress}/$id
         done
       ''
     ))