blob: 8834cb7c87f5fe6cbb706285b8a05345d5a79f21 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#
# usage:
# make infest system=foo [target=bar]
# make [deploy] system=foo [target=bar]
# make [deploy] systems='foo bar'
# make eval get=tv.wu.config.time.timeZone [filter=json]
#
.ONESHELL:
.SHELLFLAGS := -eufc
ifdef systems
$(systems):
@
unset target
parallel \
--line-buffer \
-j0 \
--no-notice \
--tagstring {} \
-q make -s systems= system={} ::: $(systems)
else ifdef system
.PHONY: deploy infest
deploy infest:;@
export get=krebs.$@
export filter=json
make -s eval | sh
.PHONY: eval
eval:
@
ifeq ($(filter),json)
extraArgs='--json --strict'
filter() { jq -r .; }
else
filter() { cat; }
endif
nix-instantiate \
$${extraArgs-} \
--eval \
-A "$$get" \
-I stockholm="$$PWD" \
'<stockholm>' \
--argstr current-date "$$(date -Is)" \
--argstr current-host-name "$$HOSTNAME" \
--argstr current-user-name "$$LOGNAME" \
$${system+--argstr system "$$system"} \
$${target+--argstr target "$$target"} \
| filter
else
$(error unbound variable: system[s])
endif
|