summaryrefslogtreecommitdiffstats
path: root/bin/list-module-imports
blob: 39d11bf349cf93307da23cde9bd50d76cc062e56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh
# list-module-imports : nix-file -> lines nix-file
set -euf

if echo "$1" | grep -q ^/; then
  :
else
  set -- "./$1"
fi

imports=$(nix-instantiate \
    -I secrets=secrets \
    --strict \
    --json \
    --eval \
    -E \
    "with builtins; with import ./lib/modules.nix; map toString (list-imports $1)")

echo "$imports" \
  | jq -r .[]