]> git.ekhem.eu.org Git - guix.git/commitdiff
[build] Simplify Makefile targets and use --derivations to clear caches.
authorJakub Czajka <jakub@ekhem.eu.org>
Sun, 22 Nov 2026 10:27:28 +0000 (10:27 +0000)
committerJakub Czajka <jakub@ekhem.eu.org>
Sun, 22 Nov 2026 10:42:39 +0000 (10:42 +0000)
Makefile

index 95646cdbc6d75c54d23e7089f8875a0f56eef158..b061e82dd5b899011af6253ef31dc06e8e2852d2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,13 @@
 # Copyright (c) 2022-2026 Jakub Czajka <jakub@ekhem.eu.org>
 # 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