Merge pull request #2233 from chiichen/nix-shell-dev

Use a more convinient way of developing rustc on NixOS
This commit is contained in:
nora 2025-02-02 08:52:17 +01:00 committed by GitHub
commit cccaff7377
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 26 deletions

View File

@ -332,28 +332,21 @@ git worktree add -b my-feature ../rust2 master
You can then use that rust2 folder as a separate workspace for modifying and
building `rustc`!
## Using nix-shell
## Working with nix
If you're using nix, you can use the following nix-shell to work on Rust:
Several nix configurations are defined in `src/tools/nix-dev-shell`.
```nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "rustc";
nativeBuildInputs = with pkgs; [
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
];
buildInputs = with pkgs; [
openssl glibc.out glibc.static
];
# Avoid creating text files for ICEs.
RUSTC_ICE = "0";
# Provide `libstdc++.so.6` for the self-contained lld.
LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [
stdenv.cc.cc.lib
]}";
}
If you're using direnv, you can create a symbol link to `src/tools/nix-dev-shell/envrc-flake` or `src/tools/nix-dev-shell/envrc-shell`
```bash
ln -s ./src/tools/nix-dev-shell/envrc-flake ./.envrc # Use flake
```
or
```bash
ln -s ./src/tools/nix-dev-shell/envrc-shell ./.envrc # Use nix-shell
```
### Note
Note that when using nix on a not-NixOS distribution, it may be necessary to set
**`patch-binaries-for-nix = true` in `config.toml`**. Bootstrap tries to detect