diff --git a/.github/workflows/debug-glibc.yml b/.github/workflows/debug-glibc.yml new file mode 100644 index 00000000..29a8975d --- /dev/null +++ b/.github/workflows/debug-glibc.yml @@ -0,0 +1,44 @@ +name: Debug nix develop environment + +on: + workflow_dispatch: + +jobs: + debug-nix: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Install Nix + uses: cachix/install-nix-action@v24 + + - name: Enter nix develop shell + run: | + nix develop --command bash -c ' + echo "πŸ”§ Nix develop shell entered" + + echo + echo "πŸ” Checking for stdlib.h" + find /nix/store -name "stdlib.h" || echo "❌ stdlib.h not found" + + echo + echo "πŸ“‚ Checking expected glibc include path" + ls -l /nix/store/*glibc*/include/stdlib.h || echo "❌ /glibc*/include/stdlib.h not found" + + echo + echo "🧠 C compiler version and paths:" + gcc --version + echo + + echo "πŸ“€ GCC include paths:" + echo | gcc -E -x c -v - + + echo + echo "πŸ“€ g++ include paths:" + echo | g++ -E -x c++ -v - + + echo + echo "βœ… Diagnostic complete" + ' \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fb04b7a2..d5e5f68d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,30 +2,32 @@ name: "test" on: push: - branches: [ main, develop ] + branches: [main, develop] pull_request: - branches: [ main, develop ] + branches: [main, develop] jobs: testbuild: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - # πŸ”΄ REQUIRED: minimal system bootstrap so bindgen/libclang can start - - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y libclang-14-dev libstdc++6 clang - - - name: Install nix + sudo apt-get install -y \ + libclang-dev \ + libstdc++6 \ + clang \ + cmake \ + pkg-config + + - name: Install Nix uses: cachix/install-nix-action@v27 with: - install_url: https://releases.nixos.org/nix/nix-2.23.3/install extra_nix_config: | - experimental-features = flakes nix-command + experimental-features = nix-command flakes - uses: cachix/cachix-action@v15 with: @@ -33,4 +35,8 @@ jobs: - name: Install and test run: | - nix develop --command bash -c "npm i && npm t" \ No newline at end of file + export LIBCLANG_PATH=$(nix eval --raw .#devShells.x86_64-linux.default.buildInputs | grep libclang | head -1)/lib + export LD_LIBRARY_PATH=$(nix eval --raw .#devShells.x86_64-linux.default.buildInputs | grep llvm | head -1)/lib:$LD_LIBRARY_PATH + export NIX_CFLAGS_COMPILE="-isystem $(nix eval --raw .#devShells.x86_64-linux.default.buildInputs | grep glibc | grep dev | head -1)/include" + export NIX_LDFLAGS="-L$(nix eval --raw .#devShells.x86_64-linux.default.buildInputs | grep glibc | grep -v dev | head -1)/lib" + nix develop --command bash -c "npm install && npm test" diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 38ec99fd..d761f396 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -175,4 +175,5 @@ If you’re unsure where code belongs, ask: If the answer is **no**, it does not belong in `shared/` or `happ/`. -That single heuristic will prevent most architectural violations. \ No newline at end of file +That single heuristic will prevent most architectural violations. + diff --git a/flake.nix b/flake.nix index da7baf4b..a975e481 100644 --- a/flake.nix +++ b/flake.nix @@ -20,33 +20,38 @@ # Pull in holonix dev shell inputsFrom = [ inputs'.holonix.devShells.default ]; - # Extra native tools (incl. libclang + libstdc++ for CI) - nativeBuildInputs = [ - pkgs.libsodium - pkgs.pkg-config - pkgs.llvmPackages.libunwind - pkgs.llvmPackages.libclang # βœ… Required by bindgen - pkgs.llvmPackages.clang-unwrapped # βœ… Needed to satisfy some crates - pkgs.stdenv.cc.cc.lib # βœ… Pulls in libstdc++.so - pkgs.cmake - ]; - packages = with pkgs; [ + # βœ… Native build toolchain + headers required on CI (Ubuntu) + stdenv.cc + glibc.dev + + # βœ… For crates like bindgen / cmake / datachannel-sys + llvmPackages.libclang + llvmPackages.clang-unwrapped + llvmPackages.libunwind + pkg-config + cmake + libsodium + + # App-specific tools nodejs_22 binaryen ]; shellHook = '' - export PS1='$begin:math:display$\\033\[1\;34m$end:math:display$[holonix:\w]\$$begin:math:display$\\033\[0m$end:math:display$ ' + export PS1='\[\033[1;34m\][holonix:\w]\$\[\033[0m\] ' - # Cross-platform: modern CMake policy + reduce configure flakiness + # πŸ›  For CMake-based crates and general safety export CMAKE_ARGS="''${CMAKE_ARGS:-} -DCMAKE_POLICY_VERSION_MINIMUM=3.10" export CMAKE_BUILD_PARALLEL_LEVEL="''${CMAKE_BUILD_PARALLEL_LEVEL:-1}" + + # βœ… Critical for CI (Ubuntu) to find stdlib headers + libs + export NIX_CFLAGS_COMPILE="-isystem ${pkgs.glibc.dev}/include" + export NIX_LDFLAGS="-L${pkgs.glibc}/lib -L${pkgs.stdenv.cc.cc.lib}/lib" '' - # macOS-only: use Apple's toolchain for native deps + pkgs.lib.optionalString pkgs.stdenv.isDarwin '' - # Requires Xcode CLT: xcode-select --install + # macOS-only: use Apple's toolchain export CC="$(xcrun -f clang)" export CXX="$(xcrun -f clang++)" export AR="$(xcrun -f ar)"