forked from rust-lang/cargo
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Joachim Schiele edited this page Jul 23, 2024
·
45 revisions
We start with rust/cargo on linux to make it work with nix as backend, see https://github.com/NixOS/nix/pull/8699 for this
- https://lastlog.de/blog/libnix_roadmap.html#cargo-with-nix-support
- https://github.com/NixOS/nix/pull/8699
- https://github.com/Anillc/nixrs/pull/1
https://github.com/nixcloud/cargo/tree/libnix-0.79.0
both folders ~/.cargo and carto/target have been removed and then a cargo build in ~/cargo will create and fill these.
Let's see what is in them!
[nixos@nixos:~/cargo]$ du -sh ~/.cargo
239M /home/nixos/.cargo
[nixos@nixos:~/cargo]$ ls ~/.cargo/
registry
[nixos@nixos:~/cargo]$ ls ~/.cargo/registry/
cache CACHEDIR.TAG index src
the example is the cargo itself, the tool coming with the rust toolchain, since we hack on it.
[nixos@nixos:~/cargo]$ du -sh target/
2.3G target/
[nixos@nixos:~/cargo]$ ls target/
CACHEDIR.TAG debug
[nixos@nixos:~/cargo]$ ls target/debug/
build cargo cargo.d deps examples incremental libcargo.d libcargo.rlib
libnix backend in cargo needs to get these things working:
- no use of ~/.cargo, everything in /nix/store
- target/debug/* needs to come from /nix/store, eventually symlinked or transparently from the store
figure out what these are:
- target/debug/build
target/debug/.fingerprint -> https://doc.rust-lang.org/nightly/nightly-rustc/cargo/core/compiler/fingerprint/index.html
[nixos@nixos:~/cargo]$ ls target/debug/.fingerprint/der-d0714c795318982b/
dep-lib-der invoked.timestamp lib-der lib-der.json
[nixos@nixos:~/cargo]$ cat target/debug/.fingerprint/der-d0714c795318982b/lib-der
6b2cf10d51d11828
[nixos@nixos:~/cargo]$ cat target/debug/.fingerprint/der-d0714c795318982b/lib-der.json | jq
{
"rustc": 18217185010275080438,
"features": "[\"alloc\", \"oid\", \"pem\", \"std\", \"zeroize\"]",
"declared_features": "",
"target": 4346314333490370059,
"profile": 12206360443249279867,
"path": 16879011525611689376,
"deps": [
[
1724196337906130016,
"pem_rfc7468",
false,
5466269655917579261
],
[
2676387858222833023,
"const_oid",
false,
2852573652909154018
],
[
15098350142499636151,
"zeroize",
false,
14469829910961900562
]
],
"local": [
{
"CheckDepInfo": {
"dep_info": "debug/.fingerprint/der-d0714c795318982b/dep-lib-der"
}
}
],
"rustflags": [],
"metadata": 12456048820742377390,
"config": 2202906307356721367,
"compile_kind": 0
}
[nixos@nixos:~/cargo]$ cat target/debug/.fingerprint/der-d0714c795318982b/dep-lib-der
finally:
- get a crate compiled without dependencies
- get one with nested dependencies
- get one with c library usage (like cargo itself)