From 7acb67b1224d557ad333dcf9ce6c0ecde5424e38 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Sun, 22 Nov 2026 10:27:28 +0000 Subject: [PATCH] [build] Simplify Makefile targets and use --derivations to clear caches. --- Makefile | 95 +++++++++++++++++++++----------------------------------- 1 file changed, 35 insertions(+), 60 deletions(-) diff --git a/Makefile b/Makefile index 95646cd..b061e82 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ # Copyright (c) 2022-2026 Jakub Czajka # License: GPL-3.0 or later. +.PHONY: stop-home-services -guix-profile := ~/.guix-home/profile -guix-store := /gnu/store -guix-version := $(shell guix show guix | sed -n '/^version/s/^.*: //gp') +guix-env := env -u GUILE_LOAD_PATH -u GUILE_LOAD_COMPILED_PATH \ + -u GUILE_EXTENSIONS_PATH GUIX_PACKAGE_PATH=$(CURDIR) + +vps-test := $(guix-env) guix build -L $(CURDIR) \ + -e '(@ (tests base) %vps-system-test)' -.PHONY: stop-home-services stop-home-services: @for svc in claude-proxy paseo-daemon; do \ ~/.guix-home/profile/bin/herd stop "$$svc" 2>/dev/null \ @@ -14,87 +16,60 @@ stop-home-services: done home-nonfree: stop-home-services - $(guix-env) GUIX_PACKAGE_PATH=$(CURDIR) PROFILE=nonfree \ - guix home reconfigure home.scm - . $(guix-profile)/etc/profile + $(guix-env) PROFILE=nonfree guix home reconfigure home.scm home-libre: stop-home-services - $(guix-env) GUIX_PACKAGE_PATH=$(CURDIR) PROFILE=libre \ - guix home reconfigure home.scm - . $(guix-profile)/etc/profile + $(guix-env) PROFILE=libre guix home reconfigure home.scm system-nonfree: - sudo GUIX_PACKAGE_PATH=`pwd` PROFILE=nonfree guix system reconfigure system.scm + sudo $(guix-env) PROFILE=nonfree guix system reconfigure system.scm system-libre: - sudo GUIX_PACKAGE_PATH=`pwd` PROFILE=libre guix system reconfigure system.scm + sudo $(guix-env) PROFILE=libre guix system reconfigure system.scm + +vps-home-module := -L $(CURDIR) -e '(@ (vps-home) vps-home-environment)' +vps-system-module := -L $(CURDIR) -e '(@ (vps-system) vps-operating-system)' vps-home: stop-home-services - $(guix-env) GUIX_PACKAGE_PATH=$(CURDIR) guix home reconfigure \ - -L $(CURDIR) -e '(@ (vps-home) vps-home-environment)' \ - --substitute-urls="https://substitutes.nonguix.org https://bordeaux.guix.gnu.org https://ci.guix.gnu.org" - . $(guix-profile)/etc/profile + $(guix-env) guix home reconfigure $(vps-home-module) vps-system: - sudo GUIX_PACKAGE_PATH=`pwd` guix system reconfigure \ - -L `pwd` -e '(@ (vps-system) vps-operating-system)' + sudo $(guix-env) guix system reconfigure $(vps-system-module) - -# Build-only targets — validate configuration without activating. -# These build derivations and cache them in the store so a -# subsequent reconfigure is near-instant. The build queue runs -# these on non-main branches; on main it runs the reconfigure -# targets directly. build-home-nonfree: - GUIX_PACKAGE_PATH=`pwd` PROFILE=nonfree \ - guix home build home.scm + $(guix-env) PROFILE=nonfree guix home build home.scm build-home-libre: - GUIX_PACKAGE_PATH=`pwd` PROFILE=libre \ - guix home build home.scm + $(guix-env) PROFILE=libre guix home build home.scm build-system-nonfree: - GUIX_PACKAGE_PATH=`pwd` PROFILE=nonfree \ - guix system build system.scm + $(guix-env) PROFILE=nonfree guix system build system.scm build-system-libre: - GUIX_PACKAGE_PATH=`pwd` PROFILE=libre \ - guix system build system.scm + $(guix-env) PROFILE=libre guix system build system.scm build-vps-system: - GUIX_PACKAGE_PATH=`pwd` guix system build \ - -L `pwd` -e '(@ (vps-system) vps-operating-system)' + $(guix-env) guix system build $(vps-system-module) build-vps-home: - GUIX_PACKAGE_PATH=`pwd` guix home build \ - -L `pwd` -e '(@ (vps-home) vps-home-environment)' - -build-vps: build-vps-system build-vps-home - -test-vps: build-vps-system build-vps-home - @out=$$(GUIX_PACKAGE_PATH=$(CURDIR) guix build -L $(CURDIR) \ - -e '(@ (tests base) %vps-system-test)' 2>/dev/null); \ - if [ -n "$$out" ] && [ -e "$$out" ]; then \ - echo "📋 Cached: $$out"; \ - echo " Run 'make test-vps-fresh' to re-execute."; \ - else \ - GUIX_PACKAGE_PATH=$(CURDIR) guix build -L $(CURDIR) \ - -e '(@ (tests base) %vps-system-test)'; \ - fi - -test-vps-fresh: build-vps-system build-vps-home - @out=$$(GUIX_PACKAGE_PATH=$(CURDIR) guix build -L $(CURDIR) \ - -e '(@ (tests base) %vps-system-test)' 2>/dev/null); \ - [ -n "$$out" ] && [ -e "$$out" ] \ - && guix gc --delete "$$out" 2>/dev/null; \ - GUIX_PACKAGE_PATH=$(CURDIR) guix build -L $(CURDIR) \ - -e '(@ (tests base) %vps-system-test)' + $(guix-env) guix home build $(vps-home-module) + +test-vps: build-vps-system + @$(vps-test) + +test-vps-fresh: build-vps-system + @drv=$$($(vps-test) --derivations 2>/dev/null); out=; \ + [ -z "$$drv" ] || out=$$(sed --quiet \ + 's/^Derive(\[("out","\([^"]*\)".*/\1/p' "$$drv"); \ + [ -z "$$out" ] || guix gc --delete "$$out" || exit 1; \ + $(vps-test) tags: - find $(guix-store) -wholename "*guix-$(guix-version)*.scm" -or \ + gv=$$($(guix-env) guix show guix | sed --quiet 's/^version: //p'); \ + find /gnu/store -wholename "*guix-$$gv*.scm" -or \ -wholename "*guix-module-union*.scm" -or \ - -wholename "*guix-system-source*.scm" | xargs etags - find `pwd` -name "*.scm" | xargs etags --append + -wholename "*guix-system-source*.scm" | xargs etags; \ + find $(CURDIR) -name "*.scm" | xargs etags --append clean: sudo guix system delete-generations -- 2.47.3