stockholm/Makefile

44 lines
1.2 KiB
Makefile
Raw Normal View History

ifndef system
$(error unbound variable: system)
2015-07-28 21:03:49 +02:00
endif
export target_host ?= $(system)
export target_user ?= root
export target_port ?= 22
export target_path ?= /var/src
2016-02-02 03:19:20 +01:00
2016-02-04 11:32:13 +01:00
evaluate = \
nix-instantiate \
--eval \
--readonly-mode \
--show-trace \
2016-02-15 16:27:11 +01:00
-I nixos-config=./$(LOGNAME)/1systems/$(system).nix \
-I stockholm=. \
2016-02-04 11:32:13 +01:00
$(1)
execute = \
result=$$($(call evaluate,-A config.krebs.build.$(1) --json)) && \
script=$$(echo "$$result" | jq -r .) && \
echo "$$script" | sh
2016-02-04 11:32:13 +01:00
# usage: make deploy system=foo [target_host=bar]
2016-02-04 11:32:13 +01:00
deploy:
$(call execute,populate)
ssh $(target_user)@$(target_host) -p $(target_port) \
2016-02-14 13:27:42 +01:00
nixos-rebuild switch --show-trace -I $(target_path)
2016-02-04 11:32:13 +01:00
# usage: make LOGNAME=shared system=wolf eval.config.krebs.build.host.name
eval eval.:;@$(call evaluate)
eval.%:;@$(call evaluate,-A $*)
2016-02-12 19:56:04 +01:00
# usage: make install system=foo [target_host=bar]
2016-02-12 23:20:50 +01:00
install: ssh ?= ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
2016-02-12 19:56:04 +01:00
install:
$(ssh) $(target_user)@$(target_host) -p $(target_port) \
2016-02-12 19:56:04 +01:00
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) -p $(target_port) \
2016-02-12 19:56:04 +01:00
env NIXOS_CONFIG=$(target_path)/nixos-config \
nixos-install