How do I pin a specific version of glibc using shell.nix?

I am trying to create a shell.nix for the sequoia project (Rust pgp implementation).

I need glibc 2.32 or greater. I thought I could simply pin a commit of nixpkgs-unstable that has 2.32 or greater but that does not seem to work.
I found 66e44425c6dfecbea68a5d6dc221ccd56561d4f1 from a PR to nixpkgs on GitHub.
I have the following:

# adapted from examples at
  # Pinned nixpkgs, deterministic
  nixpkgs = import (fetchTarball ("")) { };

  # Rolling updates, not deterministic.
  # pkgs = import (fetchTarball("channel:nixpkgs-unstable")) {};
nixpkgs.mkShell {
  buildInputs = [

anyone see what I am doing wrong? I also tried specifying glibc-2_32 and variants but that did not work.

Thank you!

1 Like

So I may have the correct shell.nix but something else is off.
I executed nix-shell --pure.
I then echoed $PATH and do see only glibc 2.32 and greater available.

The error persists after cargo clean, then cargo test.
The error I see is:

error: /nix/store/q53f5birhik4dxg3q3r2g5f324n7r5mc-glibc-2.31-74/lib/ version `GLIBC_2.32' not found (required by sequoia/target/debug/deps/

Here goes my rambling attempts at solving this compiling puzzle.

I have a feeling this is a variant of glibc-2.30 libraries link to glibc-2.27 · Issue #84043 · NixOS/nixpkgs · GitHub.
I have simplified this to:

  1. git clone
  2. nix-shell -I nixpkgs= --verbose --pure
  3. cargo check

That yields this error:

error: /nix/store/q53f5birhik4dxg3q3r2g5f324n7r5mc-glibc-2.31-74/lib/ version `GLIBC_2.32' not found (required by futures-rs/target/debug/deps/
  --> futures-macro/src/

I am running stable nixOS.

I believe the main problem is that my nixOS glibc takes precedence over what I declare in shell.nix for some reason.


Have you installed the toolchain using rustup a while ago? I’m inclined to think that you may have gc’d the glibc it was using, which is why it started whining.
I don’t think you should ever need to specify glibc in your shell’s buildInputs. --pure probably does not help either, because the rustup installations are impure.
There are ways to make this “impure” type of setup work, if you absolutely need to use rustup, otherwise I would highly suggest using or GitHub - mozilla/nixpkgs-mozilla: Mozilla overlay for Nixpkgs..


Yes! Thank you for this insight. I have rustup declared in my configuration.nix. I have imperatively installed toolchains using rustup.

I’ve also run nix-collect-garbage -d a few times since.

This sounds perfect! Rustup is not a requirement.

I approached this from what the nixos wiki had. But oxalica/rust-overlay solves my problem even more cleanly.

I tested nix-shell -p rust-bin.stable.latest.rust in a simplified project and it solved the GLIBC_2.32' not found compilation error. I am most certainly switching to that overly for Rust development on nixOS.

Thank you again @ldesgoui !

1 Like