Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closure contains Rust tool dependencies if using rust-src component in (rust-overlay) toolchain #342

Open
b-zee opened this issue Jan 23, 2025 · 0 comments

Comments

@b-zee
Copy link

b-zee commented Jan 23, 2025

When I was copying the resulting closure over SSH I noticed that the closure had (large) Rust compiler dependencies.

I am using a basic flake.nix that loads rust-toolchain.toml with rust-overlay:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    naersk.url = "github:nix-community/naersk";
    rust-overlay.url = "github:oxalica/rust-overlay";
    rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, flake-utils, naersk, rust-overlay }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        overlays = [ (import rust-overlay) ];
        pkgs = import nixpkgs { inherit system overlays; };
        toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
        naersk' = pkgs.callPackage naersk { cargo = toolchain; rustc = toolchain; clippy = toolchain; };
      in
      {
        # For `nix build` & `nix run`:
        defaultPackage = naersk'.buildPackage {
          src = ./.;
        };
      }
    );
}

And the following rust-toolchain.toml:

[toolchain]
channel = "nightly-2025-01-12"
components = [ "rust-src", "rustfmt" ]
profile = "default"

I get the following dependencies:

$ nix build && nix-store --query ./result --requisites
/nix/store/17v0ywnr3akp85pvdi56gwl99ljv95kx-gcc-14-20241116-libgcc
/nix/store/xcqcgqazykf6s7fsn08k0blnh0wisdcl-libunistring-1.3
/nix/store/34z2792zyd4ayl5186vx0s98ckdaccz9-libidn2-2.3.7
/nix/store/acfkqzj5qrqs88a4a6ixnybbjxja663d-xgcc-14-20241116-libgcc
/nix/store/65h17wjrrlsj2rj540igylrx7fqcd6vq-glibc-2.40-36
/nix/store/1c6bmxrrhm8bd26ai2rjqld2yyjrxhds-glibc-2.40-36-bin
/nix/store/kryrg7ds05iwcmy81amavk8w13y4lxbs-gmp-6.3.0
/nix/store/qs22aazzrdd4dnjf9vffl0n31hvls43h-mpfr-4.2.1
/nix/store/2a3anh8vl3fcgk0fvaravlimrqawawza-libmpc-1.3.1
/nix/store/2phvd8h14vwls0da1kmsxc73vzmhkm3b-util-linux-minimal-2.39.4-lib
/nix/store/lydgmfxkkgxn7p6rhp11cxnmq62wz237-libgpg-error-1.50
/nix/store/2qafk9zc2xf4p8ip66q59shwn6sbbaw3-libgcrypt-1.10.3-lib
/nix/store/3j1p598fivxs69wx3a657ysv3rw8k06l-pcre2-10.44
/nix/store/bpq1s72cw9qb2fs8mnmlw6hn2c7iy0ss-gcc-14-20241116-lib
/nix/store/a2byxfv4lc8f2g5xfzw8cz5q8k05wi29-gmp-with-cxx-6.3.0
/nix/store/a9jgnlhkjkxav6qrc3rzg2q84pkl2wvr-attr-2.5.2
/nix/store/cf7gkacyxmm66lwl5nj6j6yykbrg4q5c-acl-2.3.2
/nix/store/4s9rah4cwaxflicsk5cndnknqlk9n4p3-coreutils-9.5
/nix/store/5mh7kaj2fyv8mk4sfq1brwxgc02884wi-bash-5.2p37
/nix/store/cqlaa2xf6lslnizyj9xqa8j0ii1yqw0x-zlib-1.3.1
/nix/store/qbry6090vlr9ar33kdmmbq2p5apzbga8-expand-response-params
/nix/store/89p14s7lp4v48j2mdijbd56pnk90x0ms-rustc-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/6542ml6l448yr2m740xjmd31f9jiw4w9-rustfmt-preview-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/aaj9rh2v78njlmi6pyhdfyy4mzl5b8ys-libselinux-3.7
/nix/store/r04wysx6yl7ys1rdv1b1lih6in1810r0-libffi-3.4.6
/nix/store/rb870mk51kxlxq9crkldzs8n4vwr9sk4-glib-2.82.1
/nix/store/ji9vn0l5xpcvnbysc9xjsysmj07x5w8f-libsecret-0.21.4
/nix/store/a78ym5yrpjr4xl9frd4xsf79k5bwz093-cargo-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/dp6s2s3dza9818kf100hx1qqk3xf6sam-clippy-preview-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/fqyhlnrjgj35kxqbc0657kpa7ish5740-rust-docs-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/g2vnr5ppwxn981iab0vhi4gma1n1f8qs-rust-src-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/jpphwwn9j2zx929ilia3bfbn9b0ly9kc-rust-std-1.86.0-nightly-2025-01-12-x86_64-unknown-linux-gnu
/nix/store/aap6cq56amx4mzbyxp2wpgsf1kqjcr1f-gnugrep-3.11
/nix/store/pc74azbkr19rkd5bjalq2xwx86cj3cga-linux-headers-6.12
/nix/store/kj8hbqx4ds9qm9mq7hyikxyfwwg13kzj-glibc-2.40-36-dev
/nix/store/xmbv8s4p4i4dbxgkgdrdfb0ym25wh6gk-isl-0.20
/nix/store/l89iqc7am6i60y8vk507zwrzxf0wcd3v-gcc-14-20241116
/nix/store/df2a8k58k00f2dh2x930dg6xs6g6mliv-binutils-2.43.1-lib
/nix/store/j7p46r8v9gcpbxx89pbqlh61zhd33gzv-binutils-2.43.1
/nix/store/srcmmqi8kxjfygd0hyy42c8hv6cws83b-binutils-wrapper-2.43.1
/nix/store/xcn9p4xxfbvlkpah7pwchpav4ab9d135-gcc-wrapper-14-20241116
/nix/store/5rpgz0pkrs0s99sbm61nliacyq1mrx5z-rust-default-1.86.0-nightly-2025-01-12
/nix/store/817pyv9aw873svllk65dq3iivibsgnhq-nebby-0.1.0

I was able to solve this by removing the rust-src component from the toolchain:

[toolchain]
 channel = "nightly-2025-01-12"
-components = [ "rust-src", "rustfmt" ]
+components = [ "rustfmt" ]
 profile = "default"
$ nix build && nix-store --query ./result --requisites
/nix/store/17v0ywnr3akp85pvdi56gwl99ljv95kx-gcc-14-20241116-libgcc
/nix/store/xcqcgqazykf6s7fsn08k0blnh0wisdcl-libunistring-1.3
/nix/store/34z2792zyd4ayl5186vx0s98ckdaccz9-libidn2-2.3.7
/nix/store/acfkqzj5qrqs88a4a6ixnybbjxja663d-xgcc-14-20241116-libgcc
/nix/store/65h17wjrrlsj2rj540igylrx7fqcd6vq-glibc-2.40-36
/nix/store/bpq1s72cw9qb2fs8mnmlw6hn2c7iy0ss-gcc-14-20241116-lib
/nix/store/f9r9z1xfr1pznjrha1scny7fi1iccmjw-nebby-0.1.0

A workaround by overriding the components in the flake.nix (as I need the rust-src for my editor via nix dev shell):

-        toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
+        toolchain = pkgs.rust-bin.fromRustupToolchain ((builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain // { "components" = [ ]; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant