summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-02-04 11:32:13 +0100
committertv <tv@krebsco.de>2016-02-04 11:32:13 +0100
commit07a1e29b32f1c507380a252092ff85b1e69dec08 (patch)
tree04b042be4df5773d08170c11c3cc2cef7a5f8b74
parenta91803319b3d340ab9a879c11669e3e60d564572 (diff)
make eval: add some more awesome
-rw-r--r--Makefile40
1 files changed, 15 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index e82e39c7e..958629055 100644
--- a/Makefile
+++ b/Makefile
@@ -9,34 +9,24 @@ export target_host ?= $(system)
export target_user ?= root
export target_path ?= /var/src
+evaluate = \
+ nix-instantiate \
+ --arg configuration "./$$LOGNAME/1systems/$$system.nix" \
+ --eval \
+ --readonly-mode \
+ --show-trace \
+ $(1)
+
+execute = $(call evaluate,-A config.krebs.build.$(1) --json) | jq -r . | sh
+
# usage: make deploy system=foo [target_host=bar]
-.PHONY: deploy
-deploy: populate ;@set -x
+deploy:
+ $(call execute,populate)
ssh "$$target_user@$$target_host" nixos-rebuild switch -I "$$target_path"
-# usage: make populate system=foo [target_host=bar]
-.PHONY: populate
-populate:;@
- result=$$(make -s eval get=config.krebs.build.populate filter=json)
- echo "$$result" | sh
-
-# usage: make eval system=foo get=config.krebs.build [LOGNAME=tv] [filter=json]
-.PHONY: eval
-eval:;@
-ifeq ($(filter),json)
- extraArgs='--json --strict'
- filter() { echo "$$1" | jq -r .; }
-else
- filter() { echo "$$1"; }
-endif
- result=$$(nix-instantiate \
- $${extraArgs-} \
- --show-trace \
- --readonly-mode \
- --eval \
- -A "$$get" \
- --arg configuration "./$$LOGNAME/1systems/$$system.nix")
- filter "$$result"
+# usage: make LOGNAME=shared system=wolf eval.config.krebs.build.host.name
+eval eval.:;@$(call evaluate)
+eval.%:;@$(call evaluate,-A $*)
## usage: make install system=foo target=
#.PHONY: install