From b1241662052a8a3200fc3a169a2516a1ed233932 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 8 Dec 2025 00:49:36 +0100 Subject: [PATCH] Fix Nix devShell tests for multi-distro Docker images - Enable test matrix for arch, debian, ubuntu, fedora, centos - Mount /nix Docker volume only on Arch so image-local Nix installs remain visible on other distros - Keep shared Nix cache volume for all distros Details: https://chatgpt.com/share/69361196-e950-800f-ad3d-670156337b7e --- Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fe4fc1c..4c5dab0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ NIX_CACHE_VOLUME := pkgmgr_nix_cache # ------------------------------------------------------------ # Distro list and base images # ------------------------------------------------------------ -DISTROS := arch #debian ubuntu fedora centos +DISTROS := arch debian ubuntu fedora centos BASE_IMAGE_arch := archlinux:latest BASE_IMAGE_debian := debian:stable-slim @@ -82,9 +82,16 @@ test: build echo "============================================================"; \ echo ">>> Running tests in container for distro: $$distro"; \ echo "============================================================"; \ + # Nur für Arch /nix als Volume mounten, bei anderen Distros nicht, \ + # damit die im Image installierte Nix-Installation sichtbar bleibt. \ + if [ "$$distro" = "arch" ]; then \ + NIX_STORE_MOUNT='-v $(NIX_STORE_VOLUME):/nix'; \ + else \ + NIX_STORE_MOUNT=''; \ + fi; \ docker run --rm \ -v "$$(pwd):/src" \ - -v "$(NIX_STORE_VOLUME):/nix" \ + $$NIX_STORE_MOUNT \ -v "$(NIX_CACHE_VOLUME):/root/.cache/nix" \ --workdir /src \ --entrypoint bash \ @@ -108,20 +115,17 @@ test: build fi; \ \ echo "Preparing Nix environment..."; \ - # Try to source typical Nix profile scripts (if they exist) \ if [ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]; then \ . "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"; \ fi; \ if [ -f "$$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then \ . "$$HOME/.nix-profile/etc/profile.d/nix.sh"; \ fi; \ - # Hard-extend PATH for common Nix locations \ PATH="/nix/var/nix/profiles/default/bin:$$HOME/.nix-profile/bin:$$PATH"; \ export PATH; \ echo "PATH is now:"; \ echo "$$PATH"; \ \ - # Determine which Nix binary to use \ NIX_CMD=""; \ if command -v nix >/dev/null 2>&1; then \ echo "Found nix on PATH:"; \ @@ -155,7 +159,6 @@ test: build done - # ------------------------------------------------------------ # Installer for host systems (your original logic) # ------------------------------------------------------------