buildRustPackage: no matching package named `cursive`

This seems similar to this post, but that solution did not work, and is a few months old. nixos-version => 20.03pre194957.bef773ed53f (Markhor)

Issue

When running nix-build with nix derivation and Cargo.toml (to follow), I get the following error

error: no matching package named `cursive` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
required by package `unicode_util v0.1.0 (/build/unicode_util)`
builder for '/nix/store/zs4sbvgyy08827nm11d848i13n3l6cmj-unicode_util-0.1.0.drv' failed with exit code 101

Checking both crates.io and the url given in the error message, I’m able to find the package cursive for version 0.13.0, as specified. When I open a nix-shell with cargo and build, it builds without error.

Build Files

default.nix:

with import <nixpkgs> {};
let
  commandName = "unicode_util";
in
rustPlatform.buildRustPackage rec {
  name = "${commandName}-${version}";
  version = "0.1.0";

  src = ./.;

  postInstall = ''
    mkdir -p $out/share/{bash-completion/completions,zsh/site-functions,fish/vendor_completions.d}
    $out/bin/${commandName} generate_completions bash > $out/share/bash-completion/completions/${commandName}
    $out/bin/${commandName} generate_completions zsh > $out/share/zsh/site-functions/_${commandName}
    $out/bin/${commandName} generate_completions fish > $out/share/fish/vendor_completions.d/${commandName}.fish
  '';

  cargoSha256 = "1pq8wdzcrsacqxmn85n8gmh7hl0vf2xr0dpawc790x9qs335fw1k";

  meta = with stdenv.lib; {
    description = "Search unicode characters, emoji, symbols, and more";
    license = with licenses; [ mit ];
    platforms = platforms.all;
  };
}

Cargo.toml

[package]
name = "unicode_util"
version = "0.1.0"
authors = [""]
edition = "2018"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "2.33.0"
fst = "0.3.5"
fst-regex = "0.2.2"
log = "0.4.8"

[build-dependencies]
fst = "0.3.5"
xml-rs = "0.8"

[dependencies.cursive]
version = "0.13.0"
default-features = false
features = ["termion-backend"]
1 Like

I’m not totally sure what resolved this, but it’s now working.
I deleted remade the Cargo.lock file, the target directory, and a few loose files and folders that were not committed to the project. After that, it built normally.

So it seems that the fix was to update the version number in the derivation whenever a new cartes are added to Cargo.toml.