Skip to content
Joachim Schiele edited this page Jul 23, 2024 · 45 revisions

Motivation

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

Working branch

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 fill these.

~/.cargo

[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

~/cargo

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

Plan

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

finally:

  • get a crate compiled without dependencies
  • get one with nested dependencies
  • get one with c library usage (like cargo itself)

Clone this wiki locally