Compiling avr-rust book blink example: Missing avr-libc libraries

I am trying to compile the avr rust blink example from the avr-rust book, but I’m having trouble setting up the right environment.

I was expecting the pkgsCross.avr.avrlibc package to provide the runtime library needed but it doesn’t seem to, or cargo cannot find it ? Am I getting the wrong package, or is there something else I’m missing ?

I’m using a flake devShell to pull in pkgsCross.avr.buildPackages.bintools, pkgsCross.avr.buildPackages.gcc, and pkgsCross.avr.avrlibc (as well as simavr and avrdude, which shouldn’t be relevant to the issue), and running cargo build -Z build-std=core --target avr-unknown-gnu-atmega328 --release yeilds the following error

error: /nix/store/adxc893j47gxx3xjw403zdf0liiddvw2-glibc-2.32-48/lib/libc.so.6: version `GLIBC_2.33' not found (required by /dat/austreelis/prj/dev/rust/embedded/avr/blink/target/release/deps/libconst_env__value-66130893aeb46bc3.so)
  --> /home/austreelis/.cargo/registry/src/github.com-1ecc6299db9ec823/avr-config-1.0.0/src/lib.rs:15:30
   |
15 | #[allow(unused_imports)] use const_env__value::value_from_env;
   |                              ^^^^^^^^^^^^^^^^

error: /nix/store/adxc893j47gxx3xjw403zdf0liiddvw2-glibc-2.32-48/lib/libc.so.6: version `GLIBC_2.33' not found (required by /dat/austreelis/prj/dev/rust/embedded/avr/blink/target/release/deps/libconst_env__value-66130893aeb46bc3.so)
 --> /home/austreelis/.cargo/registry/src/github.com-1ecc6299db9ec823/avr-config-2.0.1/src/cpu_frequency.rs:1:30
  |
1 | #[allow(unused_imports)] use const_env__value::value_from_env;
  |                              ^^^^^^^^^^^^^^^^

error: could not compile `avr-config` due to previous error
warning: build failed, waiting for other jobs to finish...
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x4c6e23)[0x7fc0960f1e23]
/nix/store/adxc893j47gxx3xjw403zdf0liiddvw2-glibc-2.32-48/lib/libpthread.so.0(+0x13700)[0x7fc095871700]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm12MachineInstr15addRegisterDeadENS_8RegisterEPKNS_18TargetRegisterInfoEb+0xe1)[0x7fc092a0b401]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm13LiveIntervals17computeDeadValuesERNS_12LiveIntervalEPNS_15SmallVectorImplIPNS_12MachineInstrEEE+0x1c4)[0x7fc09306a0d4]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm13LiveIntervals12shrinkToUsesEPNS_12LiveIntervalEPNS_15SmallVectorImplIPNS_12MachineInstrEEE+0x481)[0x7fc0930692e1]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm13LiveRangeEdit17eliminateDeadDefsERNS_15SmallVectorImplIPNS_12MachineInstrEEENS_8ArrayRefINS_8RegisterEEEPNS_9AAResultsE+0x186)[0x7fc093067056]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(+0x2e214f3)[0x7fc0934704f3]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm12RegAllocBase16postOptimizationEv+0x17)[0x7fc093ab07a7]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(+0x29376fe)[0x7fc092f866fe]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0xaa)[0x7fc093366eda]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x6c7)[0x7fc09321e177]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x7fc09321da8f]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-13-rust-1.58.0-nightly.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x289)[0x7fc0935fa5c9]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x2448ba4)[0x7fc098073ba4]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x244395f)[0x7fc09806e95f]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x2446520)[0x7fc098071520]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x23d8b0b)[0x7fc098003b0b]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x23d325d)[0x7fc097ffe25d]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x2407320)[0x7fc098032320]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-25ea0f19be037cbe.so(+0x242c0dc)[0x7fc0980570dc]
/home/austreelis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/libstd-8adcca4f1427867b.so(rust_metadata_std_fcea40badc263c8f+0xa96b3)[0x7fc0959286b3]
/nix/store/adxc893j47gxx3xjw403zdf0liiddvw2-glibc-2.32-48/lib/libpthread.so.0(+0x8e9e)[0x7fc095866e9e]
/nix/store/adxc893j47gxx3xjw403zdf0liiddvw2-glibc-2.32-48/lib/libc.so.6(clone+0x3f)[0x7fc09578649f]
error: build failed

The glibc version used is one of my system’s glibc (nix why-depends tells me it’s not coming from my devShell env, but a few expressions from my system depends on it). There is libc.a in my $LD_LIBRARY_PATH:

for p in ${LD_LIBRARY_PATH/:/ }; do ls $p; done
avr25  avr5       avrxmega4       crtat90s1200.o  crtattiny11.o  libat90c8534.a  libat90s8535.a  libc.a           libscanf_min.a
avr3   avr51      avrxmega5       crtat90s4414.o  crtattiny12.o  libat90s1200.a  libattiny11.a   libm.a           tiny-stack
avr31  avr6       avrxmega6       crtat90s4434.o  crtattiny15.o  libat90s4414.a  libattiny12.a   libprintf_flt.a
avr35  avrtiny    avrxmega7       crtat90s8515.o  crtattiny28.o  libat90s4434.a  libattiny15.a   libprintf_min.a
avr4   avrxmega2  crtat90c8534.o  crtat90s8535.o  ldscripts      libat90s8515.a  libattiny28.a   libscanf_flt.a
libavrdude.la    libavrdude.so.1.0.0  libctf-nobfd.so        libctf.so        libsimavr.a     pkgconfig
libavrdude.so    libctf.la            libctf-nobfd.so.0      libctf.so.0      libsimavr.so
libavrdude.so.1  libctf-nobfd.la      libctf-nobfd.so.0.0.0  libctf.so.0.0.0  libsimavr.so.1

Full code here
Reproducing (hopefully) the error: nix develop -c cargo build -Z build-std=core --target avr-unknown-gnu-atmega328 --release

Edit: I originally tried setting up my environment with nix-cargo-integration, but I had other issues, with some boiling down to this one. I haven’t tried using naersk, cargo2nix or buildRustPackage directly.