stockholm/Makefile

53 lines
1,005 B
Makefile
Raw Normal View History

2015-07-19 11:50:54 +02:00
#
# usage:
2015-10-01 01:48:15 +02:00
# make infest system=foo [target=bar]
# make [deploy] system=foo [target=bar]
# make [deploy] systems='foo bar'
2015-09-27 00:22:50 +02:00
# make eval get=tv.wu.config.time.timeZone [filter=json]
2015-07-19 11:50:54 +02:00
#
2015-07-11 16:55:22 +02:00
.ONESHELL:
.SHELLFLAGS := -eufc
2015-07-19 11:50:54 +02:00
ifdef systems
$(systems):
2015-09-27 00:22:50 +02:00
@
2015-10-01 01:48:15 +02:00
unset target
2015-07-19 11:50:54 +02:00
parallel \
--line-buffer \
-j0 \
--no-notice \
--tagstring {} \
2015-09-27 00:22:50 +02:00
-q make -s systems= system={} ::: $(systems)
2015-07-19 11:50:54 +02:00
else ifdef system
2015-09-27 00:22:50 +02:00
.PHONY: deploy infest
deploy infest:;@
2015-10-01 01:48:15 +02:00
export get=krebs.$@
2015-09-27 00:22:50 +02:00
export filter=json
make -s eval | sh
2015-09-18 03:04:39 +02:00
2015-07-23 01:04:51 +02:00
.PHONY: eval
eval:
2015-07-24 17:34:08 +02:00
@
2015-07-28 21:03:49 +02:00
ifeq ($(filter),json)
2015-08-05 15:24:50 +02:00
extraArgs='--json --strict'
2015-07-28 21:03:49 +02:00
filter() { jq -r .; }
else
filter() { cat; }
endif
2015-07-24 17:34:08 +02:00
nix-instantiate \
2015-07-28 21:03:49 +02:00
$${extraArgs-} \
2015-07-23 01:04:51 +02:00
--eval \
-A "$$get" \
2015-10-15 02:48:11 +02:00
-I stockholm="$$PWD" \
2015-07-24 17:34:08 +02:00
'<stockholm>' \
2015-10-01 01:48:15 +02:00
--argstr current-date "$$(date -Is)" \
--argstr current-host-name "$$HOSTNAME" \
--argstr current-user-name "$$LOGNAME" \
$${system+--argstr system "$$system"} \
$${target+--argstr target "$$target"} \
2015-07-28 21:03:49 +02:00
| filter
2015-07-19 11:50:54 +02:00
else
$(error unbound variable: system[s])
2015-07-11 16:55:22 +02:00
endif