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 10:32:13 +00:00
|
|
|
evaluate = \
|
|
|
|
nix-instantiate \
|
2016-02-12 18:48:16 +00:00
|
|
|
--arg configuration ./$(LOGNAME)/1systems/$(system).nix \
|
2016-02-04 10:32:13 +00:00
|
|
|
--eval \
|
|
|
|
--readonly-mode \
|
|
|
|
--show-trace \
|
|
|
|
$(1)
|
|
|
|
|
2016-02-04 10:57:47 +00:00
|
|
|
execute = \
|
|
|
|
result=$$($(call evaluate,-A config.krebs.build.$(1) --json)) && \
|
|
|
|
script=$$(echo "$$result" | jq -r .) && \
|
|
|
|
echo "$$script" | sh
|
2016-02-04 10:32:13 +00:00
|
|
|
|
2016-02-04 04:40:26 +00:00
|
|
|
# usage: make deploy system=foo [target_host=bar]
|
2016-02-04 10:32:13 +00:00
|
|
|
deploy:
|
|
|
|
$(call execute,populate)
|
2016-02-12 18:48:16 +00:00
|
|
|
ssh $(target_user)@$(target_host) nixos-rebuild switch -I $(target_path)
|
2016-02-04 04:40:26 +00:00
|
|
|
|
2016-02-04 10:32:13 +00:00
|
|
|
# usage: make LOGNAME=shared system=wolf eval.config.krebs.build.host.name
|
|
|
|
eval eval.:;@$(call evaluate)
|
|
|
|
eval.%:;@$(call evaluate,-A $*)
|
2016-02-04 04:40:26 +00:00
|
|
|
|
2016-02-12 18:56:04 +00:00
|
|
|
# usage: make install system=foo [target_host=bar]
|
|
|
|
install: ssh = ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
|
|
|
|
install:
|
|
|
|
$(ssh) $(target_user)@$(target_host) \
|
|
|
|
env target_path=$(target_path) \
|
|
|
|
sh -s prepare < krebs/4lib/infest/prepare.sh
|
|
|
|
target_path=/mnt$(target_path) $(call execute,populate)
|
|
|
|
$(ssh) $(target_user)@$(target_host) \
|
|
|
|
env NIXOS_CONFIG=$(target_path)/nixos-config \
|
|
|
|
nixos-install
|