nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
352 stars 83 forks source link

Build fails with "value is a list while a string was expected" #177

Open EmJee13 opened 3 years ago

EmJee13 commented 3 years ago

I tried to use crate2nix along the "Choosing a Rust Version" readme part. My sample code had only one dependency, copypasta (version = "0.7"). Running nix-build returns the following error:

trace: warning: `buildRustCrate` is deprecated, use `buildRustCrateForPkgs` instead
error: value is a list while a string was expected, at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:23:13
(use '--show-trace' to show detailed location information)

The whole trace looks like this:

trace: warning: `buildRustCrate` is deprecated, use `buildRustCrateForPkgs` instead
error: while evaluating the attribute 'buildPhase' of the derivation 'rust_crate2nix-problem-0.1.0' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:90:5:
while evaluating anonymous function at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/build-crate.nix:2:1, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:143:18:
while evaluating 'mkRustcDepArgs' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:18:36, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/build-crate.nix:15:12:
while evaluating 'concatMapStringsSep' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/lib/strings.nix:88:5, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:19:7:
while evaluating anonymous function at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:19:36, called from undefined position:
while evaluating the attribute 'buildPhase' of the derivation 'rust_copypasta-0.7.1' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:90:5:
while evaluating anonymous function at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/build-crate.nix:2:1, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:143:18:
while evaluating 'mkRustcDepArgs' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:18:36, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/build-crate.nix:15:12:
while evaluating 'concatMapStringsSep' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/lib/strings.nix:88:5, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:19:7:
while evaluating anonymous function at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:19:36, called from undefined position:
while evaluating the attribute 'buildPhase' of the derivation 'rust_smithay-clipboard-0.6.3' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:90:5:
while evaluating anonymous function at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/build-crate.nix:2:1, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:143:18:
while evaluating 'mkRustcDepArgs' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:18:36, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/build-crate.nix:15:12:
while evaluating 'concatMapStringsSep' at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/lib/strings.nix:88:5, called from /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:19:7:
while evaluating anonymous function at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:19:36, called from undefined position:
value is a list while a string was expected, at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:23:13
wucke13 commented 3 years ago

Another instance of this can be observed when trying to build nushell:

git clone https://github.com/nushell/nushell.git
cd nushell
# the current release while I'm writing this
git checkout 0.28.0
nix-env -i -f https://github.com/kolloch/crate2nix/tarball/0.9.0
crate2nix generate
nix-env -iA nixos.niv
niv init
niv add mozilla/nixpkgs-mozilla

# Copied from crate2nix's manual
cat << 'EOF' >> nix/nixpkgs.nix                                                           
let
  # Manage this with https://github.com/nmattia/niv
  # or define { nixpkgs = ...; nixpkgs-mozilla = ...; }
  # yourself.
  sources = import ./sources.nix;

  rustChannelsOverlay = import "${sources.nixpkgs-mozilla}/rust-overlay.nix";
  # Useful if you also want to provide that in a nix-shell since some rust tools depend
  # on that.
  rustChannelsSrcOverlay = import "${sources.nixpkgs-mozilla}/rust-src-overlay.nix";

in import sources.nixpkgs {
    overlays = [
      rustChannelsOverlay
      rustChannelsSrcOverlay
      (self: super: {
        # Replace "latest.rustChannels.stable" with the version of the rust tools that
        # you would like. Look at the documentation of nixpkgs-mozilla for examples.
        #
        # NOTE: "rust" instead of "rustc" is not a typo: It will include more than needed
        # but also the much needed "rust-std".
        rustc = super.latest.rustChannels.stable.rust;
        inherit (super.latest.rustChannels.stable) cargo rust rust-fmt rust-std clippy;
      })
    ];
  }
EOF
cat << 'EOF' >> default.nix                                                                   
{ pkgs ? import ./nix/nixpkgs.nix }:

let cargoNix = pkgs.callPackage ./Cargo.nix {};
in cargoNix.workspaceMembers.nu
EOF
nix-build

Yields

trace: warning: `buildRustCrate` is deprecated, use `buildRustCrateForPkgs` instead
error: value is a list while a string was expected, at /nix/store/37ps73gpjhkbd02w5cyynqscskkvl5hm-nixpkgs-src/pkgs/build-support/rust/build-rust-crate/default.nix:23:13
(use '--show-trace' to show detailed location information)