commit 9f52b597954fbddbfc3f8e50b3d14bdaff8266f7 parent 248c0470ca46f7515c49b4655425c01747b947b1 Author: Vincent Demeester <vincent@sbr.pm> Date: Wed, 4 May 2022 09:48:11 +0200 Makefile: refactor a bit Re-use nixos-rebuild for local and remote build. Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | Makefile | | | 56 | +++++++++++++++++++++++++++++++++++++++++--------------- |
1 file changed, 41 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile @@ -1,4 +1,30 @@ # Makefile for home +HOSTS = $(shell nix flake show --json | yq '.nixosConfigurations.[] | key') +HOSTS_BUILD = $(addprefix host/, $(addsuffix /build,$(HOSTS))) +BUILDER_HOST = root@shikoku.home + +hosts: ${HOSTS_BUILD} + echo ${HOSTS_BUILD} ${HOSTS} + +host/%/build: FORCE + nix build .#nixosConfigurations.$*.config.system.build.toplevel --no-link +host/%/boot: FORCE + nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@$*.home --flake .#$* boot +host/%/switch: FORCE + nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@$*.home --flake .#$* switch + +boot: + sudo nixos-rebuild --flake .# boot +switch: + sudo nixos-rebuild --flake .# switch +dry-build: + sudo nixos-rebuild --flake .# dry-build +build: + sudo nixos-rebuild --flake .# build + +FORCE: + +# Old – to be removed # Variables EMACS = ifndef EMACS @@ -17,21 +43,21 @@ all: switch update: nix-channel --update -.PHONY: build -build: - ./bin/system build - -.PHONY: nixos-dry-build -dry-build: setup - ./bin/system dry-build - -.PHONY: switch -switch: - ./bin/system switch - -.PHONY: boot -boot: - ./bin/system boot +# .PHONY: build +# build: +# ./bin/system build +# +# .PHONY: nixos-dry-build +# dry-build: setup +# ./bin/system dry-build +# +# .PHONY: switch +# switch: +# ./bin/system switch +# +# .PHONY: boot +# boot: +# ./bin/system boot .PHONY: install-hooks install-hooks: