summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ca828fd2b4768a0cdea20a5c1b2e755a131990ca (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
#
# usage:
#		make system=foo
#		make systems='foo bar'
#		make eval system=foo get=config.networking.extraHosts [filter=json]
#

.ONESHELL:
.SHELLFLAGS := -eufc

ifdef systems
$(systems):
	parallel \
		--line-buffer \
		-j0 \
		--no-notice \
		--tagstring {} \
		-q make systems= system={} ::: $(systems)
else ifdef system
.PHONY: deploy
deploy:;@
	make eval system=$(system) get=config.krebs.build.script filter=json | sh

.PHONY: eval
eval:
	@
ifeq ($(filter),json)
	extraArgs=--json
	filter() { jq -r .; }
else
	filter() { cat; }
endif
	NIX_PATH=stockholm=$$PWD:$$NIX_PATH \
	nix-instantiate \
		$${extraArgs-} \
		$${json+--json} \
		$${json+--strict} \
		--eval \
		-A "$$get" \
		'<stockholm>' \
		--argstr user-name "$$LOGNAME" \
		--argstr system-name "$$system" \
		| filter
else
$(error unbound variable: system[s])
endif