Commit 32f8bd2e4896
Changed files (1)
Makefile
@@ -1,7 +1,4 @@
# Makefile for home
-HOSTS = $(shell nix flake show --json --all-systems 2>/dev/null | yq '.nixosConfigurations.[] | key')
-HOSTS_BUILD = $(addprefix host/, $(addsuffix /build,$(HOSTS)))
-
.PHONY: all
all: help
@@ -17,8 +14,13 @@ help: ## Show this help message
##@ Host Operations (Remote)
.PHONY: hosts
-hosts: ${HOSTS_BUILD} ## List and build all hosts
- echo ${HOSTS_BUILD} ${HOSTS}
+hosts: ## List and build all hosts
+ @json="$$(nix eval --json .#nixosConfigurations --apply builtins.attrNames)" || exit $$?; \
+ hosts="$$(printf '%s\n' "$$json" | yq -r '.[]')" || exit $$?; \
+ [ -n "$$hosts" ] || { echo 'No NixOS hosts found' >&2; exit 1; }; \
+ set --; for host in $$hosts; do set -- "$$@" "host/$$host/build"; done; \
+ echo "$$@"; \
+ $(MAKE) "$$@"
host/%/build: FORCE ## Build a specific remote host (e.g., make host/demeter/build)
nix build .#nixosConfigurations.$*.config.system.build.toplevel --no-link