make {deploy2 -> populate, rebuild}

This commit is contained in:
tv 2016-02-02 03:19:20 +01:00
parent 2497533b90
commit b849e3525e

View File

@ -27,30 +27,6 @@ deploy infest:;@
script=$$(make -s eval) script=$$(make -s eval)
echo "$$script" | sh echo "$$script" | sh
.PHONY: deploy2
ifdef target
deploy2: export target-host = $(target)
else
deploy2: export target-host = $(system)
endif
deploy2: export source = \
with (import ~/stockholm {}).users.$(LOGNAME).$(system).config.krebs.build; \
assert source-version == 2; \
source
deploy2:;@
target=$${target-$$system}
result=$$(nix-instantiate \
--eval \
--json \
--arg source "$$source" \
--argstr target-host "$$target" \
--argstr target-path /var/src \
-A populate \
krebs/v2)
script=$$(echo "$$result" | jq -r .)
echo "$$script" | sh
ssh root@$$target nixos-rebuild switch -I /var/src
.PHONY: eval .PHONY: eval
eval: eval:
@ @
@ -73,6 +49,33 @@ endif
$${target+--argstr target "$$target"}) $${target+--argstr target "$$target"})
echo "$$result" | filter echo "$$result" | filter
ifndef target
export target = $(system)
endif
# usage: make populate system=foo [target=bar]
.PHONY: populate
populate: export source = \
with (import ~/stockholm {}).users.$(LOGNAME).$(system).config.krebs.build; \
assert source-version == 2; \
source
populate:;@
result=$$(nix-instantiate \
--eval \
--json \
--arg source "$$source" \
--argstr target-host "$$target" \
--argstr target-path /var/src \
-A populate \
krebs/v2)
script=$$(echo "$$result" | jq -r .)
echo "$$script" | sh
# usage: make rebuild system=foo [target=bar] [operation=switch]
.PHONY: rebuild
rebuild: populate ;@
ssh root@"$$target" nixos-rebuild "$${operation-switch}" -I /var/src
else else
$(error unbound variable: system[s]) $(error unbound variable: system[s])
endif endif