blob: e82e39c7e0e18bf41b2486b527035dc6c6d0eb41 (
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
|
.ONESHELL:
.SHELLFLAGS := -eufc
ifndef system
$(error unbound variable: system)
endif
export target_host ?= $(system)
export target_user ?= root
export target_path ?= /var/src
# usage: make deploy system=foo [target_host=bar]
.PHONY: deploy
deploy: populate ;@set -x
ssh "$$target_user@$$target_host" nixos-rebuild switch -I "$$target_path"
# usage: make populate system=foo [target_host=bar]
.PHONY: populate
populate:;@
result=$$(make -s eval get=config.krebs.build.populate filter=json)
echo "$$result" | sh
# usage: make eval system=foo get=config.krebs.build [LOGNAME=tv] [filter=json]
.PHONY: eval
eval:;@
ifeq ($(filter),json)
extraArgs='--json --strict'
filter() { echo "$$1" | jq -r .; }
else
filter() { echo "$$1"; }
endif
result=$$(nix-instantiate \
$${extraArgs-} \
--show-trace \
--readonly-mode \
--eval \
-A "$$get" \
--arg configuration "./$$LOGNAME/1systems/$$system.nix")
filter "$$result"
## usage: make install system=foo target=
#.PHONY: install
#install: ssh = ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
#install:;@set -x
# $(ssh) "$$target_user@$$target_host" \
# env target_path=/var/src \
# sh -s prepare < krebs/4lib/infest/prepare.sh
# make -s populate target_path=/mnt"$$target_path"
# $(ssh) "$$target_user@$$target_host" \
# env NIXOS_CONFIG=/var/src/nixos-config \
# nixos-install
|