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
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?
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)
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.
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
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)
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
# unless "Build the derivation" isn't
sudo nixos-rebuild switch
got help in nixos discord
posting my solution here in case others need it
thanks so much to @nobbz and @0adk for helping me solve this problem, and everyone on here
# configuration.nix
environment.systemPackages = with pkgs; [
inputs.unstable.legacyPackages.x86_64-linux.ncspot
# other packages
];