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
This commit is contained in:
15
Makefile
15
Makefile
@@ -10,7 +10,7 @@ NIX_CACHE_VOLUME := pkgmgr_nix_cache
|
|||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Distro list and base images
|
# Distro list and base images
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
DISTROS := arch #debian ubuntu fedora centos
|
DISTROS := arch debian ubuntu fedora centos
|
||||||
|
|
||||||
BASE_IMAGE_arch := archlinux:latest
|
BASE_IMAGE_arch := archlinux:latest
|
||||||
BASE_IMAGE_debian := debian:stable-slim
|
BASE_IMAGE_debian := debian:stable-slim
|
||||||
@@ -82,9 +82,16 @@ test: build
|
|||||||
echo "============================================================"; \
|
echo "============================================================"; \
|
||||||
echo ">>> Running tests in container for distro: $$distro"; \
|
echo ">>> Running tests in container for distro: $$distro"; \
|
||||||
echo "============================================================"; \
|
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 \
|
docker run --rm \
|
||||||
-v "$$(pwd):/src" \
|
-v "$$(pwd):/src" \
|
||||||
-v "$(NIX_STORE_VOLUME):/nix" \
|
$$NIX_STORE_MOUNT \
|
||||||
-v "$(NIX_CACHE_VOLUME):/root/.cache/nix" \
|
-v "$(NIX_CACHE_VOLUME):/root/.cache/nix" \
|
||||||
--workdir /src \
|
--workdir /src \
|
||||||
--entrypoint bash \
|
--entrypoint bash \
|
||||||
@@ -108,20 +115,17 @@ test: build
|
|||||||
fi; \
|
fi; \
|
||||||
\
|
\
|
||||||
echo "Preparing Nix environment..."; \
|
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 \
|
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"; \
|
. "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"; \
|
||||||
fi; \
|
fi; \
|
||||||
if [ -f "$$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then \
|
if [ -f "$$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then \
|
||||||
. "$$HOME/.nix-profile/etc/profile.d/nix.sh"; \
|
. "$$HOME/.nix-profile/etc/profile.d/nix.sh"; \
|
||||||
fi; \
|
fi; \
|
||||||
# Hard-extend PATH for common Nix locations \
|
|
||||||
PATH="/nix/var/nix/profiles/default/bin:$$HOME/.nix-profile/bin:$$PATH"; \
|
PATH="/nix/var/nix/profiles/default/bin:$$HOME/.nix-profile/bin:$$PATH"; \
|
||||||
export PATH; \
|
export PATH; \
|
||||||
echo "PATH is now:"; \
|
echo "PATH is now:"; \
|
||||||
echo "$$PATH"; \
|
echo "$$PATH"; \
|
||||||
\
|
\
|
||||||
# Determine which Nix binary to use \
|
|
||||||
NIX_CMD=""; \
|
NIX_CMD=""; \
|
||||||
if command -v nix >/dev/null 2>&1; then \
|
if command -v nix >/dev/null 2>&1; then \
|
||||||
echo "Found nix on PATH:"; \
|
echo "Found nix on PATH:"; \
|
||||||
@@ -155,7 +159,6 @@ test: build
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Installer for host systems (your original logic)
|
# Installer for host systems (your original logic)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user