Fix crown on NixOS (#30987)

* Fix crown on NixOS

* no need to install libs, because there are none

* fix program name in usage message

* use the cargo provided by each buildPhase

* cargo update --offline can be used to reformat lockfiles

* document how to keep rust-toolchain.toml and etc/shell.nix in sync

* clarify comment about allowBuiltinFetchGit

* fix license

* clarify purpose of filterlock

* explain why crown must not use workspace dependencies
This commit is contained in:
Delan Azabani 2024-01-05 10:15:16 +08:00 committed by GitHub
parent 21d9c2cc63
commit c219204084
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 328 additions and 5 deletions

View file

@ -174,6 +174,8 @@ about build scripts like
"Could not run \`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=\\"1\\" PKG_CONFIG_ALLOW_SYSTEM_LIBS=\\"1\\"
\\"pkg-config\\" \\"--libs\\" \\"--cflags\\" \\"fontconfig\\"\`
* (if you are on NixOS) [ERROR rust_analyzer::main_loop] FetchWorkspaceError: rust-analyzer failed to load workspace: Failed to load the project at /path/to/servo/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /path/to/servo/Cargo.toml, Some(Version { major: 1, minor: 74, patch: 1 }): Failed to run `cd "/path/to/servo" && "cargo" "metadata" "--format-version" "1" "--manifest-path" "/path/to/servo/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"`: `cargo metadata` exited with an error: error: could not execute process `crown -vV` (never executed)
This is because the rustflags (flags passed to the rust compiler) that standard `cargo` provides are
different to what `./mach` uses, and so every time Servo is built using `cargo` it will undo all the
work done by `./mach` (and vice versa).
@ -203,8 +205,18 @@ the amount of disc space used).
}
```
If you are on NixOS, these settings should be enough to not need to run `code .` from within a
`nix-shell etc/shell.nix`, but it wouldnt hurt to try that if you still have problems.
If you are on NixOS, you should also set CARGO_BUILD_RUSTC in `.vscode/settings.json` as follows,
where `/nix/store/.../crown` is the output of `nix-shell etc/shell.nix --run 'command -v crown'`.
These settings should be enough to not need to run `code .` from within a `nix-shell etc/shell.nix`,
but it wouldnt hurt to try that if you still have problems.
```
{
"rust-analyzer.server.extraEnv": {
"CARGO_BUILD_RUSTC": "/nix/store/.../crown",
},
}
```
When enabling rust-analyzers proc macro support, you may start to see errors like