Skip to content

cargo clean (retain store paths during build) #4

@qknight

Description

@qknight

Problem

It would be great if we could remove a bunch of irrelevant store paths without having to call "nix-collect-garbage" to clear all by using cargo clean.

This ticket is a draft.

~/.cargo

Legacy cargo clean removes the /target folder per project but leaves the ~/.cargo/ files untouched. For reference, my ~/.cargo has 5.8 Gb of files:

  • git 1.3gb
  • registry 4.0 gb
  • bin 51 mb

These things should all be in the /nix/store and the bin should be a symlink. But this is not the topic of this ticket.

{{project_dir}}/target

The nix-backend in cargo already stores dep downloads like serde into /nix/store and also builds it in /nix/store but currently there exists no clear concept for tracking and removal.

current gc

Currently cargo build creates target/debug/nix/gc/result with the intent to prevent the removal:

  • of download+intermediate build artifacts (deps)
  • root crate artefacts

on nix-collect-garbage.

a list of store paths

At the moment the cargo toolchain consists of (target/debug/nix/cargo_build_caller.nix)

  • fenix rustc
  • build_parser
  • nixpkgs checkout

The actual build dependencies are in:

  • cargoPackages

Some of these can be discovered with: nix show-derivation

nix show-derivation /nix/store/4jqb4cjy6zp8c1pyqp0n2zy91d35b6in-cargo-0_88_0-bin-85e09d7d8299b1ad/bin/cargo | jq -r '.[].inputDrvs | keys[]'
...
/nix/store/xzirgb8m1zpfc496q91234c19pz13lm8-gix-lock-16_0_0-c0e4d3d42bd1d641.drv
/nix/store/y27n4zbylxiz8g0nm8br0rsnx1bsj6q9-logone-0_2_7-1eb55177eedd2e91.drv
/nix/store/y2qkszspj8sxvvj7fnahz7znf1h3cgph-darling-0_20_10-cbd8405b60358367.drv
/nix/store/ybidv07j6qz6b1d2hr7h552h1lrqkbv3-git2-0_20_0-a5a6e57aa11f1a77.drv
/nix/store/ywn37nmzl4jfdk06djwcibj91ds26mpg-gix-validate-0_9_3-5cd523d9060c9684.drv
/nix/store/ywzplrdm5324fssj0qrfyw48z40zahyd-nom-7_1_3-f13dd91924a7c5d9.drv
/nix/store/yzyd5kw1sl24cv69hc0ib6z5cfq33apz-openssl-probe-0_1_6-6d5d5ac82de655f5.drv
/nix/store/z44svagx0wh0y632mr8amva0gspn2n7l-parking_lot_core-0_9_10-e6343e9285ac5c5a.drv
/nix/store/z5a45f7jgw8c245c7w24a9389khdvqg4-overload-0_1_1-36d6dc4b2c1d5222.drv
/nix/store/zbhpk1rnsydn0z60m65yg38jk04hdz6s-sized-chunks-0_6_5-e757fe722119bf9b.drv
/nix/store/zjhhdydsc9igv2zhigv6qq22cm8im53z-fiat-crypto-0_2_9-92e05bb23b31efe5.drv
/nix/store/zl9xrvkl7814cw9w7hvr4wg4acdjj0cq-gix-hashtable-0_7_0-cf7f65c45ebb5acb.drv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions