diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -24,7 +24,8 @@ else ifdef system deploy infest:;@ export get=krebs.$@ export filter=json - make -s eval | sh + script=$$(make -s eval) + echo "$$script" | sh .PHONY: eval eval: @@ -48,6 +49,40 @@ endif $${target+--argstr target "$$target"}) echo "$$result" | filter +export target_host ?= $(system) +export target_user ?= root +export target_path ?= /var/src + +# usage: make populate system=foo [target_host=bar] +.PHONY: populate +populate: export lib = \ + let nlib = import <nixpkgs/lib>; in \ + nlib // import krebs/4lib { lib = nlib; } // builtins +populate: export source = \ + with builtins; \ + with (import ./. {}).users.$${getEnv "LOGNAME"}.$${getEnv "system"}; \ + assert config.krebs.build.source-version == 2; \ + config.krebs.build.source +populate:;@ + result=$$(nix-instantiate \ + --eval \ + --json \ + --arg lib "$$lib" \ + --arg source "$$source" \ + --argstr target-user "$$target_user" \ + --argstr target-host "$$target_host" \ + --argstr target-path "$$target_path" \ + -A populate \ + krebs/v2) + script=$$(echo "$$result" | jq -r .) + echo "$$script" | sh + +# usage: make rebuild system=foo [target_host=bar] [operation=switch] +.PHONY: rebuild +rebuild: populate ;@set -x + ssh "$$target_user@$$target_host" \ + nixos-rebuild "$${operation-switch}" -I "$$target_path" + else $(error unbound variable: system[s]) endif |