Skip to content

Commit 3b6fba1

Browse files
committed
fix(flake/macos): Guard the Linux-specific bits to restore operation on macOS
1 parent 57b00ea commit 3b6fba1

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

flake.nix

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
in {
1313
devShells = forEachSystem (system: let
1414
pkgs = import nixpkgs {inherit system;};
15+
isLinux = pkgs.stdenv.isLinux;
16+
isDarwin = pkgs.stdenv.isDarwin;
1517
in {
1618
default = pkgs.mkShell {
1719
packages = with pkgs; [
@@ -28,21 +30,27 @@
2830
llvmPackages.clang # Clang compiler used by bindgen for parsing C headers
2931
pkg-config # Used by build scripts to find library paths
3032

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-
3533
# For build automation
3634
just
3735
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
3840
];
3941

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
4143

4244
# LIBCLANG_PATH: Required by bindgen to locate libclang shared library
4345
# Without this, bindgen fails with "couldn't find any valid shared libraries" error
4446
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
4547

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 {
4654
# BINDGEN_EXTRA_CLANG_ARGS: Additional clang arguments for bindgen when parsing Ruby headers
4755
# Includes system header paths that are not automatically discovered in NixOS
4856
# --sysroot ensures clang can find standard C library headers like stdarg.h
@@ -52,12 +60,6 @@
5260
"-I${glibc.dev}/include" # System C headers
5361
"--sysroot=${glibc.dev}" # System root for header resolution
5462
];
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++";
6163
};
6264
});
6365
};

0 commit comments

Comments
 (0)