@@ -203,3 +203,74 @@ git worktree add -b my-feature ../rust2 master
203
203
204
204
You can then use that rust2 folder as a separate workspace for modifying
205
205
and building ` rustc ` !
206
+
207
+ ## Using nix-shell
208
+
209
+ If you're using nix, you can use the following nix-shell to work on Rust:
210
+
211
+ ``` nix
212
+ { pkgs ? import <nixpkgs> {} }:
213
+
214
+ # This file contains a development shell for working on rustc.
215
+ let
216
+ # Build configuration for rust-lang/rust. Based on `config.toml.example` from
217
+ # `1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5`.
218
+ config = pkgs.writeText "rustc-config" ''
219
+ profile = "compiler" # you may want to choose a different profile, like `library` or `tools`
220
+ changelog-seen = 2
221
+
222
+ [build]
223
+ # The path to (or name of) the GDB executable to use. This is only used for
224
+ # executing the debuginfo test suite.
225
+ gdb = "${pkgs.gdb}/bin/gdb"
226
+ python = "${pkgs.python3Full}/bin/python"
227
+
228
+ [rust]
229
+ debug = true
230
+ incremental = true
231
+ deny-warnings = false
232
+
233
+ # Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
234
+ # sysroot.
235
+ llvm-tools = true
236
+
237
+ # Print backtrace on internal compiler errors during bootstrap
238
+ backtrace-on-ice = true
239
+ '';
240
+
241
+ ripgrepConfig =
242
+ let
243
+ # Files that are ignored by ripgrep when searching.
244
+ ignoreFile = pkgs.writeText "rustc-rgignore" ''
245
+ configure
246
+ config.toml.example
247
+ x.py
248
+ LICENSE-MIT
249
+ LICENSE-APACHE
250
+ COPYRIGHT
251
+ **/*.txt
252
+ **/*.toml
253
+ **/*.yml
254
+ **/*.nix
255
+ *.md
256
+ src/ci
257
+ src/etc/
258
+ src/llvm-emscripten/
259
+ src/llvm-project/
260
+ src/rtstartup/
261
+ src/rustllvm/
262
+ src/stdsimd/
263
+ src/tools/rls/rls-analysis/test_data/
264
+ '';
265
+ in
266
+ pkgs.writeText "rustc-ripgreprc" "--ignore-file=${ignoreFile}";
267
+ in
268
+ pkgs.mkShell {
269
+ name = "rustc";
270
+ nativeBuildInputs = with pkgs; [
271
+ gcc9 binutils cmake ninja openssl pkgconfig python39 git curl cacert patchelf nix psutils
272
+ ];
273
+ RIPGREP_CONFIG_PATH = ripgrepConfig;
274
+ RUST_BOOTSTRAP_CONFIG = config;
275
+ }
276
+ ```
0 commit comments