Skip to content

example in README.md doesn't work with rust-toolchain.toml file #287

@woss

Description

@woss

Following the example that is given in the README.md

# shell.nix
let
  moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
  nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
in
  with nixpkgs;
  stdenv.mkDerivation {
    name = "moz_overlay_shell";
    buildInputs = [
      # to use the latest nightly:
      #nixpkgs.latest.rustChannels.nightly.rust
      # to use a specific nighly:
      # (nixpkgs.rustChannelOf { date = "2018-04-11"; channel = "nightly"; }).rust
      # to use the project's rust-toolchain file:
      (nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain.toml; }).rust
    ];
  }

and my rust-toolchain.toml

[toolchain]
channel = "nightly-2022-02-23"
components = ["rustfmt", "rustc-dev", "rust-std", "rust-analysis", "rust-src"]
targets = ["wasm32-unknown-unknown", "x86_64-unknown-linux-gnu"]
profile = "default"

fails when I change the rust-toolchain to rust-toolchain.toml with the following error:

❯ nix-shell --pure  shell.nix
error: unable to download 'https://static.rust-lang.org/dist/channel-rust-nightly-2022-02-23.toml': HTTP error 404 ('')
(use '--show-trace' to show detailed location information)

Then I run it with the show-trace

❯ nix-shell --pure --show-trace shell.nix
error: unable to download 'https://static.rust-lang.org/dist/channel-rust-nightly-2022-02-23.toml': HTTP error 404 ('')

       … while evaluating 'flip'

       at /nix/store/b6n2pql0s2fval4hy7mczy1l9rq9v3yd-nixpkgs-21.11pre326916.7053541084b/nixpkgs/lib/trivial.nix:138:16:

          137|   */
          138|   flip = f: a: b: f b a;
             |                ^
          139|

       … from call site

       at /nix/store/5snmi8nb601c90swp17b96g3a1622366-source/rust-overlay.nix:269:5:

          268|     in
          269|     flip mapAttrs pkgs.pkg (name: pkg:
             |     ^
          270|       makeOverridable ({extensions, targets, targetExtensions}:

       … while evaluating 'fromManifestFile'

       at /nix/store/5snmi8nb601c90swp17b96g3a1622366-source/rust-overlay.nix:262:32:

          261|   #                       you will need to specify this extension in the extensions options or it will not be installed!
          262|   fromManifestFile = manifest: { stdenv, lib, fetchurl, patchelf }:
             |                                ^
          263|     let

       … from call site

       at /nix/store/5snmi8nb601c90swp17b96g3a1622366-source/rust-overlay.nix:318:8:

          317|     let manifestFile = if sha256 == null then builtins.fetchurl manifest else fetchurl { url = manifest; inherit sha256; };
          318|     in fromManifestFile manifestFile { inherit stdenv lib fetchurl patchelf; };
             |        ^
          319|while evaluating 'fromManifest'

       at /nix/store/5snmi8nb601c90swp17b96g3a1622366-source/rust-overlay.nix:316:36:

          315|
          316|   fromManifest = sha256: manifest: { stdenv, lib, fetchurl, patchelf }:
             |                                    ^
          317|     let manifestFile = if sha256 == null then builtins.fetchurl manifest else fetchurl { url = manifest; inherit sha256; };

       … from call site

       at /nix/store/5snmi8nb601c90swp17b96g3a1622366-source/rust-overlay.nix:330:59:

          329|
          330|   rustChannelOf = { sha256 ? null, ... } @ manifest_args: fromManifest
             |                                                           ^
          331|     sha256 (manifest_v2_url manifest_args)

       … while evaluating 'rustChannelOf'

       at /nix/store/5snmi8nb601c90swp17b96g3a1622366-source/rust-overlay.nix:330:19:

          329|
          330|   rustChannelOf = { sha256 ? null, ... } @ manifest_args: fromManifest
             |                   ^
          331|     sha256 (manifest_v2_url manifest_args)

       … from call site

       at /home/daniel/projects/work/anagolay/operations/op-cid/shell.nix:14:8:

           13|       # to use the project's rust-toolchain file:
           14|       (nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain.toml; }).rust
             |        ^
           15|     ];while evaluating anonymous lambda

       at /nix/store/b6n2pql0s2fval4hy7mczy1l9rq9v3yd-nixpkgs-21.11pre326916.7053541084b/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:156:13:

          155|       (map (drv: drv.__spliced.hostHost or drv) depsHostHost)
          156|       (map (drv: drv.crossDrv or drv) buildInputs)
             |             ^
          157|     ]

       … from call site

       … while evaluating 'getOutput'

       at /nix/store/b6n2pql0s2fval4hy7mczy1l9rq9v3yd-nixpkgs-21.11pre326916.7053541084b/nixpkgs/lib/attrsets.nix:489:23:

          488|   */
          489|   getOutput = output: pkg:
             |                       ^
          490|     if ! pkg ? outputSpecified || ! pkg.outputSpecified

       … from call site

       … while evaluating the attribute 'buildInputs' of the derivation 'moz_overlay_shell'

       at /nix/store/b6n2pql0s2fval4hy7mczy1l9rq9v3yd-nixpkgs-21.11pre326916.7053541084b/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let

I am not well versed in the nix lang so I cannot even debug this. i found this #281 and thought it should work without any issues, but it seems it doesn't for me.

Is there something I am doing wrong or this is a bug? thx

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