Building rustc in NixOS

I’m looking to implement a fix to rustc, but am having trouble getting it to build on NixOS. A hacky workaround I’ve been using so far is to install some packages globally via home-manager (e.g. llvmPackages.bintools-unwrapped and glibc) so that I can have them available without needing a shell.nix or flake.nix (which the Rust repo doesn’t have).

But I’ve got stuck at this error message, when linking with cc:

   = note: /nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: cannot find -lutil: No such file or directory
           /nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: cannot find -lrt: No such file or directory
           /nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: cannot find -lpthread: No such file or directory
           /nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: cannot find -lm: No such file or directory
           /nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: cannot find -ldl: No such file or directory
           /nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: cannot find -lc: No such file or directory

I’m not super familiar with Nix, so I guess this is a two-part question:

  1. Does anyone here build rustc on NixOS and have a working config? Or understands this error/how to fix it?
  2. Is there a better way to work with codebases that don’t use Nix, but require certain system libraries to be present?

Thanks :grin:

I expect that there are not many people building rustc using nix. But I would recommend to write a shell.nix or flake.nix (whichever is more easy to you) and add it to your fork and share it when you are stuck.