Skip to content

Commit 22c2f7c

Browse files
authored
make shell.nix better (rust-lang#1858)
* make shell.nix better * Mention using RUST_BOOTSTRAP_CONFIG * Move things to `buildInputs` and add `glibc.out glibc.static` This fixes the nofile-limit.rs UI test. * short lines for the short line fans * Fix pkgs
1 parent 45a9ad1 commit 22c2f7c

File tree

1 file changed

+24
-57
lines changed

1 file changed

+24
-57
lines changed

src/building/suggested.md

+24-57
Original file line numberDiff line numberDiff line change
@@ -276,67 +276,34 @@ If you're using nix, you can use the following nix-shell to work on Rust:
276276

277277
```nix
278278
{ pkgs ? import <nixpkgs> {} }:
279-
280-
# This file contains a development shell for working on rustc.
281-
let
282-
# Build configuration for rust-lang/rust. Based on `config.example.toml` (then called
283-
# `config.toml.example`) from `1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5`
284-
config = pkgs.writeText "rustc-config" ''
285-
profile = "compiler" # you may want to choose a different profile, like `library` or `tools`
286-
287-
[build]
288-
patch-binaries-for-nix = true
289-
# The path to (or name of) the GDB executable to use. This is only used for
290-
# executing the debuginfo test suite.
291-
gdb = "${pkgs.gdb}/bin/gdb"
292-
python = "${pkgs.python3Full}/bin/python"
293-
294-
[rust]
295-
debug = true
296-
incremental = true
297-
deny-warnings = false
298-
299-
# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
300-
# sysroot.
301-
llvm-tools = true
302-
303-
# Print backtrace on internal compiler errors during bootstrap
304-
backtrace-on-ice = true
305-
'';
306-
307-
ripgrepConfig =
308-
let
309-
# Files that are ignored by ripgrep when searching.
310-
ignoreFile = pkgs.writeText "rustc-rgignore" ''
311-
configure
312-
config.example.toml
313-
x.py
314-
LICENSE-MIT
315-
LICENSE-APACHE
316-
COPYRIGHT
317-
**/*.txt
318-
**/*.toml
319-
**/*.yml
320-
**/*.nix
321-
*.md
322-
src/ci
323-
src/etc/
324-
src/llvm-emscripten/
325-
src/llvm-project/
326-
src/rtstartup/
327-
src/rustllvm/
328-
src/stdsimd/
329-
src/tools/rls/rls-analysis/test_data/
330-
'';
331-
in
332-
pkgs.writeText "rustc-ripgreprc" "--ignore-file=${ignoreFile}";
333-
in
334279
pkgs.mkShell {
335280
name = "rustc";
336281
nativeBuildInputs = with pkgs; [
337-
gcc_multi binutils cmake ninja openssl pkgconfig python39 git curl cacert patchelf nix psutils
282+
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
283+
];
284+
buildInputs = with pkgs; [
285+
openssl glibc.out glibc.static
338286
];
339-
RIPGREP_CONFIG_PATH = ripgrepConfig;
287+
# Avoid creating text files for ICEs.
288+
RUSTC_ICE = "0";
289+
}
290+
```
291+
292+
Note that when using nix on a not-NixOS distribution, it may be necessary to set
293+
**`patch-binaries-for-nix = true` in `config.toml`**.
294+
Bootstrap tries to detect whether it's running in nix and enable patching automatically,
295+
but this detection can have false negatives.
296+
297+
You can also use your nix shell to manage `config.toml`:
298+
299+
```nix
300+
let
301+
config = pkgs.writeText "rustc-config" ''
302+
# Your config.toml content goes here
303+
''
304+
pkgs.mkShell {
305+
/* ... */
306+
# This environment varaible tells bootstrap where our config.toml is.
340307
RUST_BOOTSTRAP_CONFIG = config;
341308
}
342309
```

0 commit comments

Comments
 (0)