Skip to content

Commit cccaff7

Browse files
authored
Merge pull request #2233 from chiichen/nix-shell-dev
Use a more convinient way of developing rustc on NixOS
2 parents de20137 + 72ceb93 commit cccaff7

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

Diff for: src/building/suggested.md

+19-26
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,24 @@ and follow the same instructions as above.
135135
### Emacs
136136

137137
Emacs provides support for rust-analyzer with project-local configuration
138-
through [Eglot](https://www.gnu.org/software/emacs/manual/html_node/eglot/).
138+
through [Eglot](https://www.gnu.org/software/emacs/manual/html_node/eglot/).
139139
Steps for setting up Eglot with rust-analyzer can be [found
140-
here](https://rust-analyzer.github.io/manual.html#eglot).
140+
here](https://rust-analyzer.github.io/manual.html#eglot).
141141
Having set up Emacs & Eglot for Rust development in general, you can run
142142
`./x setup editor` and select `emacs`, which will prompt you to create
143143
`.dir-locals.el` with the recommended configuration for Eglot.
144-
The recommended settings live at [`src/etc/rust_analyzer_eglot.el`].
144+
The recommended settings live at [`src/etc/rust_analyzer_eglot.el`].
145145
For more information on project-specific Eglot configuration, consult [the
146146
manual](https://www.gnu.org/software/emacs/manual/html_node/eglot/Project_002dspecific-configuration.html).
147147

148148
### Helix
149149

150-
Helix comes with built-in LSP and rust-analyzer support.
150+
Helix comes with built-in LSP and rust-analyzer support.
151151
It can be configured through `languages.toml`, as described
152-
[here](https://docs.helix-editor.com/languages.html).
152+
[here](https://docs.helix-editor.com/languages.html).
153153
You can run `./x setup editor` and select `helix`, which will prompt you to
154154
create `languages.toml` with the recommended configuration for Helix. The
155-
recommended settings live at [`src/etc/rust_analyzer_helix.toml`].
155+
recommended settings live at [`src/etc/rust_analyzer_helix.toml`].
156156

157157
## Check, check, and check again
158158

@@ -181,7 +181,7 @@ example, running `tidy` and `linkchecker` is useful when editing Markdown files,
181181
whereas UI tests are much less likely to be helpful. While `x suggest` is a
182182
useful tool, it does not guarantee perfect coverage (just as PR CI isn't a
183183
substitute for bors). See the [dedicated chapter](../tests/suggest-tests.md) for
184-
more information and contribution instructions.
184+
more information and contribution instructions.
185185

186186
Please note that `x suggest` is in a beta state currently and the tests that it
187187
will suggest are limited.
@@ -332,29 +332,22 @@ git worktree add -b my-feature ../rust2 master
332332
You can then use that rust2 folder as a separate workspace for modifying and
333333
building `rustc`!
334334

335-
## Using nix-shell
335+
## Working with nix
336336

337-
If you're using nix, you can use the following nix-shell to work on Rust:
337+
Several nix configurations are defined in `src/tools/nix-dev-shell`.
338338

339-
```nix
340-
{ pkgs ? import <nixpkgs> {} }:
341-
pkgs.mkShell {
342-
name = "rustc";
343-
nativeBuildInputs = with pkgs; [
344-
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
345-
];
346-
buildInputs = with pkgs; [
347-
openssl glibc.out glibc.static
348-
];
349-
# Avoid creating text files for ICEs.
350-
RUSTC_ICE = "0";
351-
# Provide `libstdc++.so.6` for the self-contained lld.
352-
LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [
353-
stdenv.cc.cc.lib
354-
]}";
355-
}
339+
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`
340+
341+
```bash
342+
ln -s ./src/tools/nix-dev-shell/envrc-flake ./.envrc # Use flake
343+
```
344+
or
345+
```bash
346+
ln -s ./src/tools/nix-dev-shell/envrc-shell ./.envrc # Use nix-shell
356347
```
357348

349+
### Note
350+
358351
Note that when using nix on a not-NixOS distribution, it may be necessary to set
359352
**`patch-binaries-for-nix = true` in `config.toml`**. Bootstrap tries to detect
360353
whether it's running in nix and enable patching automatically, but this

0 commit comments

Comments
 (0)