2015-07-11 14:55:22 +00:00
|
|
|
.ONESHELL:
|
|
|
|
.SHELLFLAGS := -eufc
|
2015-07-19 09:50:54 +00:00
|
|
|
|
2016-02-04 04:40:26 +00:00
|
|
|
ifndef system
|
|
|
|
$(error unbound variable: system)
|
2015-07-28 19:03:49 +00:00
|
|
|
endif
|
2015-12-22 19:31:21 +00:00
|
|
|
|
2016-02-02 02:51:22 +00:00
|
|
|
export target_host ?= $(system)
|
|
|
|
export target_user ?= root
|
|
|
|
export target_path ?= /var/src
|
2016-02-02 02:19:20 +00:00
|
|
|
|
2016-02-04 04:40:26 +00:00
|
|
|
# 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"
|
|
|
|
|
2016-02-02 02:51:22 +00:00
|
|
|
# usage: make populate system=foo [target_host=bar]
|
2016-02-02 02:19:20 +00:00
|
|
|
.PHONY: populate
|
|
|
|
populate:;@
|
2016-02-04 04:40:26 +00:00
|
|
|
result=$$(make -s eval get=config.krebs.build.populate filter=json)
|
|
|
|
echo "$$result" | sh
|
2016-02-02 02:19:20 +00:00
|
|
|
|
2016-02-04 04:40:26 +00:00
|
|
|
# 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 .; }
|
2015-07-19 09:50:54 +00:00
|
|
|
else
|
2016-02-04 04:40:26 +00:00
|
|
|
filter() { echo "$$1"; }
|
2015-07-11 14:55:22 +00:00
|
|
|
endif
|
2016-02-04 04:40:26 +00:00
|
|
|
result=$$(nix-instantiate \
|
|
|
|
$${extraArgs-} \
|
|
|
|
--show-trace \
|
|
|
|
--readonly-mode \
|
|
|
|
--eval \
|
|
|
|
-A "$$get" \
|
2016-02-04 04:52:06 +00:00
|
|
|
--arg configuration "./$$LOGNAME/1systems/$$system.nix")
|
2016-02-04 04:40:26 +00:00
|
|
|
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
|