Skip to content

Conversation

@szlend
Copy link

@szlend szlend commented Apr 24, 2025

I'd like to be able to override stdenv so that for example all C dependencies get built with clang instead of gcc.

This is quite tricky to do as you can't just pass any stdenv override to the toolchain because the toolchain can be placed into different contexts (e.g. nativeBuildInputs where splicing is offset by -1).

I haven't been able to find a better solution than accepting a stdenvSelector function. This picks the stdenv from the context of the toolchain derivation so it's always correctly offset.

toolchain.override { stdenvSelector = pkgs: pkgs.llvmPackages_19.stdenv; }

The selector function also allows you to pick a different stdenv depending on the platform, which could be useful when cross-compiling, say you want a different stdenv per build/host/target platform:

toolchain.override { stdenvSelector = pkgs: if pkgs.stdenv.isDarwin then pkgs.llvmPackages_19.stdenv else pkgs.stdenv; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant