|
12 | 12 | in { |
13 | 13 | devShells = forEachSystem (system: let |
14 | 14 | pkgs = import nixpkgs {inherit system;}; |
| 15 | + isLinux = pkgs.stdenv.isLinux; |
| 16 | + isDarwin = pkgs.stdenv.isDarwin; |
15 | 17 | in { |
16 | 18 | default = pkgs.mkShell { |
17 | 19 | packages = with pkgs; [ |
|
28 | 30 | llvmPackages.clang # Clang compiler used by bindgen for parsing C headers |
29 | 31 | pkg-config # Used by build scripts to find library paths |
30 | 32 |
|
31 | | - # C standard library headers required for Ruby C extension compilation |
32 | | - # Without this, build fails with "stdarg.h file not found" error |
33 | | - glibc.dev |
34 | | - |
35 | 33 | # For build automation |
36 | 34 | just |
37 | 35 | git-lfs |
| 36 | + ] ++ pkgs.lib.optionals isLinux [ |
| 37 | + # C standard library headers required for Ruby C extension compilation on Linux |
| 38 | + # Without this, build fails with "stdarg.h file not found" error |
| 39 | + glibc.dev |
38 | 40 | ]; |
39 | 41 |
|
40 | | - # Environment variables required to fix NixOS-specific build issues with rb-sys/bindgen |
| 42 | + # Environment variables required to fix build issues with rb-sys/bindgen |
41 | 43 |
|
42 | 44 | # LIBCLANG_PATH: Required by bindgen to locate libclang shared library |
43 | 45 | # Without this, bindgen fails with "couldn't find any valid shared libraries" error |
44 | 46 | LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; |
45 | 47 |
|
| 48 | + # Compiler environment variables to ensure consistent toolchain usage |
| 49 | + # These help rb-sys and other build scripts use the correct clang installation |
| 50 | + CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; |
| 51 | + CC = "${pkgs.llvmPackages.clang}/bin/clang"; |
| 52 | + CXX = "${pkgs.llvmPackages.clang}/bin/clang++"; |
| 53 | + } // pkgs.lib.optionalAttrs isLinux { |
46 | 54 | # BINDGEN_EXTRA_CLANG_ARGS: Additional clang arguments for bindgen when parsing Ruby headers |
47 | 55 | # Includes system header paths that are not automatically discovered in NixOS |
48 | 56 | # --sysroot ensures clang can find standard C library headers like stdarg.h |
|
52 | 60 | "-I${glibc.dev}/include" # System C headers |
53 | 61 | "--sysroot=${glibc.dev}" # System root for header resolution |
54 | 62 | ]; |
55 | | - |
56 | | - # Compiler environment variables to ensure consistent toolchain usage |
57 | | - # These help rb-sys and other build scripts use the correct clang installation |
58 | | - CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; |
59 | | - CC = "${pkgs.llvmPackages.clang}/bin/clang"; |
60 | | - CXX = "${pkgs.llvmPackages.clang}/bin/clang++"; |
61 | 63 | }; |
62 | 64 | }); |
63 | 65 | }; |
|
0 commit comments