Path to cargo lock file doesn't exist [ncspot (fix) 1.3.1]

Expected behaviour:
cargo lock file to be detected in this fix

What I got:

error: path '/nix/store/[VERY LONG HASH]-source/ncspot-Cargo.lock' does not exist

system.stateVersion = “24.11”
ncspot 1.3.1

I’ve followed this very cool fix to try to get ncspot working again (after spotify pushed even more breaking changes that break even ncspot 1.3.1)
As I’m pretty new to Nixos, I cannot make out 100% what’s going on. Neither where to put it. Tried in configuration.nix and home.nix

{ config, pkgs, inputs, lib, ... }:
let
  #fix here
in
{
  # A or B part of fix here (A in home.nix, B in configuration.nix)
}

but both seem to throw the error. I don’t see where in my code I try to install some ncspot-Cargo, and I also don’t see where in his code that is installed aswell (yet I have no clue what it truly does).
I have cargo installed
I am trying to install ncspot with this patch
It doesn’t find the cargo lock file

EDIT:
Why can’t it find the lock file?

You’re almost certainly using flakes and a git repo and have forgotten to git add the new file.

Assuming you copied stuff from the PR the lines where that file becomes relevant are these:

    cargoLock = {
      lockFile = ./ncspot-Cargo.lock;
      outputHashes = {
        "librespot-core-0.7.1" = "sha256-oNmFHtdjt8e7EE8QCjQ2zDtK1zcyMRFvfHM/2ZBm374=";
      };
    };

I mean, that, or you forget to follow the first step:

Step 1: Download the Cargo.lock file to your config directory:

curl -o ncspot-Cargo.lock https://raw.githubusercontent.com/gui-wf/ncspot/fix/librespot-spotifyuri-api/Cargo.lock
2 Likes

both running step 1 without and with sudo, the error still persists
ran with --show-trace for more info (it becomes like 4 screens long)

while evaluating derivation 'ncspot-1.3.1-fix-librespot-spotifyuri-api'
whose name attribute is located at /nix/store/fnc4632ncr5k5la19gp2gb255dx8pi9x-source/pkgs/stdenv/generic/make-derivation.nix:375:7

… while evaluating attribute 'cargoDeps' of derivation 'ncspot-1.3.1-fix-librespot-spotifyuri-api'
at /nix/store/fnc4632ncr5k5la19gp2gb255dx8pi9x-source/pkgs/build-support/rust/build-rust-package/default.nix:79:7:
78|     // {
79|       cargoDeps =
|       ^
80|         if cargoVendorDir != null then

… while calling the 'getAttr' builtin
at <nix/derivation-internal.nix>:44:19:
43|       value = commonAttrs // {
44|         outPath = builtins.getAttr outputName strict;
|                   ^
45|         drvPath = strict.drvPath;

… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:34:12:
33|
34|   strict = derivationStrict drvAttrs;
|            ^
35|

… while evaluating derivation 'cargo-vendor-dir'
whose name attribute is located at /nix/store/fnc4632ncr5k5la19gp2gb255dx8pi9x-source/pkgs/stdenv/generic/make-derivation.nix:375:7

… while evaluating attribute 'buildCommand' of derivation 'cargo-vendor-dir'
at /nix/store/fnc4632ncr5k5la19gp2gb255dx8pi9x-source/pkgs/build-support/trivial-builders/default.nix:63:17:
62|         enableParallelBuilding = true;
63|         inherit buildCommand name;
|                 ^
64|         passAsFile = [ "buildCommand" ]

error: path '/nix/store/y4wrq317lkarpdb43yf247xz0djwnnil-source/ncspot-Cargo.lock' does not exist

cargo 1.85.0
(despite having pkgs.rustc installed, getting the version throws this error)

error: command failed: 'rustc': No such file or directory (os error 2)

thinking they might be related somehow
EDIT:
If it can’t find rustc - that should be installed - then maybe it can’t find the lock-file somehow, that also should be there.

No, that’s not how any of this works. You don’t need random software “installed” on NixOS - “installation” is practically a meaningless concept here, what is or what isn’t in $PATH constantly changes. Even if it did mean something, this is an error happening at evaluation time, nix is telling you it’s missing a file that should exist, this has nothing to do with rust. Also, nix’ build sandbox will include rust, you don’t need it in your user’s $PATH.

The problem here is that ./ncspot-Cargo.lock doesn’t exist in the directory where your package override is. You’ve either downloaded the lockfile into a random unrelated directory, or you are using flakes, and the flake heuristic of “is this file tracked by git” isn’t tracking because you didn’t git add it.

Given the specifics of your output I’m pretty sure you’re using flakes, at least.

I can’t tell you which of the two issues it is without seeing what files you have or commands you are running. Could you share the output of:

$ find /etc/nixos

As well as ideally the contents of your flake.nix, configuration.nix and home.nix, as well as any other modules you’ve written?

1 Like

thanks for the quick reply :smiley:

gobbe@nixos ~> find /etc/nixos
/etc/nixos
/etc/nixos/mods
/etc/nixos/flake.lock
/etc/nixos/configuration.nix
/etc/nixos/flake.nix
/etc/nixos/home.nix
/etc/nixos/hardware-configuration.nix

also here are configuration, home and flake files (before trying to add this fix, both home and flake were pm empty :P)

EDIT:
also sorry for most of the comments being in swedish, can translate specific stuff if you need more info around it :q

Move the ncspot-Cargo.lock you downloaded into the /etc/nixos directory.

I moved the downloaded file (downloaded from step 1) into /etc/nixos. Instead of my home where I’d accidentally installed it before :c

But it seems to not have the correct hash for librespot-core-0.7.1

error: A hash was specified for librespot-core-0.7.1, but there is no corresponding git dependency.

Think it might be related to that change merging into ncspot 1.3.2
No clue how to find the correct hash though, can’t seem to find any real docs surrounding it, some steps that kind of assume that I own the git repo (which I don’t :P)

I mean… if you use the exact code you linked you’re not doing that.

Could you share what you have now?

1 Like

In the outputHashes block, the new dependency is for librespot-core-0.8.0 (not …0.7.1).
Copy-pasting code without reading it will cause you infinite headaches.

Set the hash to the empty string "", build, let the error tell you what the hash is, then replace the "" with a string containing the hash.

EDIT: also a better question, why not just use the existing PR? ncspot: 1.3.1 -> 1.3.2 by Zocker1999NET · Pull Request #461001 · NixOS/nixpkgs · GitHub

2 Likes

was still getting the same error (but now for librespot-core-0.8.0)
even after setting hash to “”
but tried removing the outputhashes completely. And suddenly, it builds :smiley:

Didn’t use PR because it didn’t exist when I started, and I couldn’t figure out how to install from it (still kinda can’t) :stuck_out_tongue:

EDIT: ok the build stopped after realising that it didn’t have proper deps. Still happy something’s happening (:

To fix the issue:
> 1. Set cargoHash/cargoSha256 to an empty string: `cargoHash = "";`
> 2. Build the derivation and wait for it to fail with a hash mismatch
> 3. Copy the "got: sha256-..." value back into the cargoHash field
>    You should have: cargoHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";

Did this exactly but I’m not getting a hash :frowning:

# unless "Build the derivation" isn't 
sudo nixos-rebuild switch

got help in nixos discord
posting my solution here in case others need it :stuck_out_tongue:
thanks so much to @nobbz and @0adk for helping me solve this problem, and everyone on here :hugs:

# configuration.nix
environment.systemPackages = with pkgs; [
  inputs.unstable.legacyPackages.x86_64-linux.ncspot
  # other packages
];
# flake.nix
inputs = 
  unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};