#!/bin/bash # Script to test the Nix flake in Docker set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" IMAGE_NAME="meshcore-packet-capture-nix-test" CONTAINER_NAME="meshcore-packet-capture-test" # Build the Docker image echo "Building Docker image..." docker build -f Dockerfile.nix-test -t "$IMAGE_NAME" . # Run the container with the repository mounted echo "Starting container..." docker run -it --rm \ --name "$CONTAINER_NAME" \ -v "$SCRIPT_DIR:/workspace" \ -w /workspace \ "$IMAGE_NAME" \ /bin/bash -c " source /root/.nix-profile/etc/profile.d/nix.sh echo '=== Testing flake structure ===' nix flake show || true echo '' echo '=== Testing package build ===' nix build .#packages.x86_64-linux.default --no-link || true echo '' echo '=== Testing module syntax ===' nix-instantiate --eval -E ' let pkgs = import {}; lib = pkgs.lib; flakeModule = import ./nix/nixos-module.nix { flake-parts-lib = {}; }; nixosModule = flakeModule.flake.nixosModules.default; in lib.isFunction nixosModule ' --strict || true echo '' echo '=== Testing module with minimal config ===' nix-instantiate --eval -E ' let pkgs = import {}; lib = pkgs.lib; flakeModule = import ./nix/nixos-module.nix { flake-parts-lib = {}; }; nixosModule = flakeModule.flake.nixosModules.default; eval = import { modules = [ nixosModule { services.meshcore-packet-capture = { enable = true; connectionType = \"ble\"; mqtt1 = { enabled = true; server = \"localhost\"; port = 1883; }; package = pkgs.hello; # Use a dummy package for testing }; } ]; }; in eval.config.services.meshcore-packet-capture.enable ' --strict || true echo '' echo '=== Interactive shell available ===' echo 'Run: docker exec -it $CONTAINER_NAME /bin/bash' /bin/bash "