Closed NL-TCH closed 1 year ago
Mmmm it builds for me, three things:
home-manager
module, indeed I set home.packages = [spotify-adblocked];
. So if you are importing it directly into your NixOS configuration you probably have to change that line to something like environment.systemPackages
. Probably you already did this right however, the error you got happens when you build derivations, not when you evaluate modules.spotifywm
derivation fails to build during the installPhase
. But the error you get seems to come from the stdenv setup script which is weird. Maybe it tells you that the error is there but it really is in the installPhase
. Possibly you use a mac and when you copy/pasted this your editor added that \r
to the installPhase
? To exclude this you can try setting installPhase
to an in inline string "mkdir -p $out/lib && cp spotifywm.so $out/lib/"
.nixpkgs
) and tell me if it works please!hey, thanks for the fast answer!
i indeed changed the home.packages
to environment.systemPackages
i have tried a lot of things and variations but the build keeps failing with the same error (used the packages spotifywm, used the sourcecode of the official winrm package in the nixrepo,
applied your fix with installPhase = "mkdir -p $out/lib && cp spotifywm.so $out/lib/";
but it seems to keep failing.
really weird.
(also updated the snap spotify package and used a newer version of the official spotify pkgs nix source code)
thanks again for the help, but the error seems to be in the installphase which i have changed multiple times with multiple install phases.
i got more output, but the same error:
building '/nix/store/75b106lablhy8jg3b4ciwc9w972wl058-spotifywm.drv'...
unpacking sources
unpacking source archive /nix/store/9m6wlhrdmas4czlhm5wbya70br20s1d3-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
build flags: SHELL=/nix/store/7q1b1bsmxi91zci6g8714rcljl620y7f-bash-5.2-p15/bin/bash
g++ -Wall -Wextra -O3 -shared -fPIC -static-libgcc -lX11 -DSONAME="spotifywm.so" -o spotifywm.so spotifywm.cpp
g++ -Wall -Wextra -O3 -shared -fPIC -static-libgcc -lX11 spotifywm.cpp spotifywm.so -o spotifywm
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/z8908a1ckyjzhrva1djliffmvm6gx8d6-spotifywm
shrinking /nix/store/z8908a1ckyjzhrva1djliffmvm6gx8d6-spotifywm/lib/spotifywm.so
checking for references to /build/ in /nix/store/z8908a1ckyjzhrva1djliffmvm6gx8d6-spotifywm...
patching script interpreter paths in /nix/store/z8908a1ckyjzhrva1djliffmvm6gx8d6-spotifywm
stripping (with command strip and flags -S -p) in /nix/store/z8908a1ckyjzhrva1djliffmvm6gx8d6-spotifywm/lib
building '/nix/store/nag1k0aq4c54cxy29hdhll6fmr0jc6hg-spotify-1.2.11.916.geb595a67.drv'...
unpacking sources
/nix/store/5wdlffjhcr4i43sfajxcvx3lvnkryh5y-stdenv-linux/setup: line 1604: $'\r': command not found
or is the new error from the installphase of spotify-adblocked?
This seems to be a new error, I mean, it's the same error but when building spotify-adblocked
, spotify-wm
was built this time.
But are you on Darwin or not? Is it possible that your editor adds carriage returns (\r
) in the installPhase
string?
Have you also updated nixpkgs
?
the logs state:
nix-store --read-log /nix/store/5vxs4s9nr3g7bpcifj5q25q723f1l1gn-spotify-1.1.84.716.gc5f8b819.drv
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
/nix/store/5wdlffjhcr4i43sfajxcvx3lvnkryh5y-stdenv-linux/setup: line 1604: $'\r': command not found
i use vscode to edit the .nix files and i am using windows to edit, and a VM (with shared folders) to execute.
the unpack phase looks as following:
unpackPhase = ''
runHook preUnpack
unsquashfs "$src" '/usr/share/spotify' '/usr/bin/spotify' '/meta/snap.yaml'
cd squashfs-root
if ! grep -q 'grade: stable' meta/snap.yaml; then
# Unfortunately this check is not reliable: At the moment (2018-07-26) the
# latest version in the "edge" channel is also marked as stable.
echo "The snap package is marked as unstable:"
grep 'grade: ' meta/snap.yaml
echo "You probably chose the wrong revision."
exit 1
fi
if ! grep -q '${version}' meta/snap.yaml; then
echo "Package version differs from version found in snap metadata:"
grep 'version: ' meta/snap.yaml
echo "While the nix package specifies: ${version}."
echo "You probably chose the wrong revision or forgot to update the nix version."
exit 1
fi
runHook postUnpack
'';
If you use VScode from Windows I highly suspect that it's replacing carriage returns with newline in your sources when you save files. I had a similar problem in the past using VSCode with WSL on Windows.
is the error in the install or unpack phase of spotify-adblock?
Oh you are right, this time the error occurs during the unpack phase.
i have not updated nixpkgs, is it needed, how?
I'm quite sure that the reason is carriage returns. However it depends, if your configuration is a flake then you have nixpkgs
between your inputs and you can update it with something like nix flake lock --update-input nixpkgs
. Otherwise use if you are using channels the command should be nix-channel --update
.
Try to do what they say here. You want to read LF
, not CRLF
.
hahaha that was it, the linebreak from CRLF to LF did the job
wow it was a rabbithole into nix packaging but thank you so much for the time and effort!! do you have a 'buy me a coffee' link?
Glad it worked! :rocket:
do you have a 'buy me a coffee' link?
I'm honored by the offer, it's the first that someone asks me this. I'm enabling sponsoring on GH just for you :smile: (I've no idea how it works, my request is pending now).
PS: let me know if the adblocker really works, please
will do, i was developing on a VM, i'll login once i reload on my laptop thanks again!
spotify.zip i've got it working with the newest spotify version (1.2.11 instead of your 1.1.84)
when i start a playlist and skip around no ads appear so i think it is working (for now)
Great! However while probably nixpkgs
isn't the best place for this package it would be nice putting it in NUR in my opinion. If you ever make a PR tag me please. I'll do the same in case.
https://github.com/nix-community/NUR/pull/574
https://github.com/NL-TCH/nur-packages
pullrequest is in progress, i'll keep you up to date
Great job! If you want you could try to not copy/paste the derivation in spotify-adblocked.nix
from nixpkgs
but use the one from nixpkgs
overriding the installPhase
with overrideAttrs
. It would be a little cleaner in my opinion, this way you will be able to update nixpkgs
with nix flake lock --update-input nixpkgs
and you would get the newer spotify version from nixpkgs
. Obviously it's on you checking if your overrode installPhase
still works with the newer Spotify derivation from nixpkgs
.
An even better thing would be creating a new entirely derivation that depends on the the upstream Spotify derivation from nixpkgs
. This way you would take advantage of the official binary cache downloading the already built spotify and having to build just your "wrapped derivation".
I quickly tried both the approach IIRC but in the end they weren't as easy as what I did. Also I didn't have further time to spend on this.
is this what you mean? i have it working via the NUR with the override function instead of the derivation
(see the readme:) https://github.com/NL-TCH/nur-packages
Exactly! The only thing I find unsatisfactory is that you had to rewrite the installPhase
entirely and are not using prev
. Usually with overrideAttrs
you do something like
spotify.overrideAttrs (old: {
installPhase = old.installPhase + ''
# appended stuff here
'';
})
Or the opposite:
spotify.overrideAttrs (old: {
installPhase = ''
# prepended stuff here
'' + old.installPhase;
})
Otherwise if something in the upstream installPhase
is changed you have to check it by hand and copy/paste it again to your code. In this case, when I quickly did this, I couldn't find any way to avoid copy/pasting the entire installPhase
.
I could use builtins.(match|split|replaceStrings)
to change old.installPhase
injecting what you need in the middle of the phase but it looked too hacky and flaky. At that point it was better copy/pasting it.
Alternatively, the best option in my opinion would be creating an entirely new derivation that depends on the upstream spotify
patching it. As said above you would leverage on the official binary cache.
Something like:
pkgs.runCommand "spotify-wrapped" { } ''
cp -rf ${pkgs.spotify} $out
patchelf /bin/spotify --magic-arg ${pkgs.spotifywm} # argument is invented
''
thanks for the feedback, i get exactly what you mean but this is way above my skillset and understanding.nix for now i am happy with the result (just started a few days ago with nix-os and nix-pkgs). if you want to help me with code feel free to make a pullrequest.
thanks for your time and expertise!
Don't worry, if you started a few days ago you already learned a lot of stuff. If I'll have time I'll make a PR, meanwhile I'm using your NUR package now.
PS: if you want to offer me a coffee now you can! It should be possible making a one time donation by an arbitrary amount from my GH profile clicking on "sponsor".
thanks for using my repo, its an honor. and i am looking forward to merging your PR (ofcourse if you have time)
btw, sinds when did github stop paypal sponsoring?! i don't have a credit card. you can send me your paypaladdress via discord if you want (discordusername: nl_tch)
Nooooo :sob: I really wanted to have a sponsor on GH. I didn't know it doesn't support PayPal :disappointed: I like the idea of a sponsor visible on my GH profile.
I've quickly checked some alternatives like liberapay, patreon and others but can't choose, so probably I will not choose.
Don't worry about that and happy hacking with Nix. I don't use Discord often but you can reach me almost 24/7 on Matrix @aciceri:nixos.dev
PS: otherwise i can give you my Ethereum address, but it's better using L2s, otherwise it's more for fees than for the coffee itself@aciceri:nixos.dev
Hey @aciceri i found your repository via the following issue: https://github.com/NixOS/nixpkgs/issues/209784
i copied your spotify folder (including default.nix and spotify-adblocked.nix) and refered to those via my configuration.nix:
but the build is failing, do you have any resolution or fix? i am quite new to the packaging and overriding of nix packages.
the
nixos-rebuild switch
log: