summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-02-02 03:19:20 +0100
committertv <tv@krebsco.de>2016-02-02 03:19:20 +0100
commitb849e3525edfe884a2e004e6497aad9995c093bd (patch)
treeedd54383d8a1cd32830935fb74aa4085429f491b /Makefile
parent2497533b90ce901a39d6642923738b2a337ad9aa (diff)
make {deploy2 -> populate, rebuild}
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile51
1 files changed, 27 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index d7534e1f3..ecfc7e50d 100644
--- a/Makefile
+++ b/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