Skip to content

Add support for packaging C toolchains managed by Nix#2698

Open
IvarWithoutBones wants to merge 1 commit into
mozilla:mainfrom
IvarWithoutBones:dist-nix-toolchain
Open

Add support for packaging C toolchains managed by Nix#2698
IvarWithoutBones wants to merge 1 commit into
mozilla:mainfrom
IvarWithoutBones:dist-nix-toolchain

Conversation

@IvarWithoutBones
Copy link
Copy Markdown

@IvarWithoutBones IvarWithoutBones commented May 6, 2026

The way the Nix package manager structures C compilers is a bit different from other systems. Executables installed in $PATH are thin wrapper scripts over the actual compiler binaries, which inject the paths to runtime dependencies like libc and the standard library headers.

The wrapper being a shell script breaks the usual method of finding dependencies. ldd doesn't work on shell scripts, a specific script interpreter is required, and the script refers to dependencies like coreutils by their (unpredictable) Nix store paths.

Luckily Nix provides a way to query the runtime dependencies of any file in the store, so we can simply add those to the toolchain package instead of trying to find them by hand. Programs like as are included as well. I've tested distributed compilation with various (cross) compilers from Nix, which all work as expected. Rust toolchains also already worked as expected before this PR.

Fixes #1684.

The way the Nix package manager structures C compilers is a bit different
from other systems. Executables installed in $PATH are thin wrappers over
the actual compiler binaries, which inject the paths to runtime
dependencies like libc and the standard library headers.

The wrapper being a shell script breaks the usual method of finding
dependencies. `ldd` doesn't work on shell scripts, a specific script
interpreter is required, and the script refers to dependencies like
`coreutils` by their (unpredictable) Nix store paths.

Luckily Nix provides a way to query the runtime dependencies of any
file in the store, so we can simply add those to the toolchain
package instead of trying to find them ourselves.
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.

sccache toolchain packaging and NixOS

1 participant