summaryrefslogtreecommitdiffstats
path: root/bin/make-rsync-filter
blob: 26e070adbb5f14b308fd4f012e341b4fc70cb254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /bin/sh
# make-rsync-filter : nixos-config -> rsync-filter
set -euf

main=$1

hosts=$(list-hosts)
module_imports=$(list-module-imports "$main")
other_imports=$(
  echo "$module_imports" \
    | xargs grep -H . \
    | import-statements \
    | slash-path-relpath \
    | undot-paths \
    | sort \
    | uniq \
    | sed '/\.nix$/!s:$:/default.nix:' \
    )
secrets=$(echo "$module_imports" | xargs cat | quoted-strings | filter-secrets)

# TODO collect all other paths from *_imports

abs_deps=$(
  echo "$hosts"
  echo "$module_imports"
  echo "$other_imports"
  echo "$secrets"
)

rel_deps=$(echo "$abs_deps" | make-relative-to "$PWD")
filter=$(echo "$rel_deps" | make-rsync-whitelist)

echo "$filter"