make {deploy2 -> populate, rebuild}
This commit is contained in:
parent
2497533b90
commit
b849e3525e
51
Makefile
51
Makefile
@ -27,30 +27,6 @@ deploy infest:;@
|
||||
script=$$(make -s eval)
|
||||
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
|
||||
eval:
|
||||
@
|
||||
@ -73,6 +49,33 @@ endif
|
||||
$${target+--argstr target "$$target"})
|
||||
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
|
||||
$(error unbound variable: system[s])
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user