How to make a derivation depend on another derivation

Hello Everyone, I was trying to build a derivation for GitHub - cococry/lyssa: Aestethic, minimal, suckless music player which depends on other libraries libclipoard and taglib which do not exist in nixpkgs, so I wrote custom derivations for both of them, but It is failing and I couldnt figure out whay I am doing wrong. Here is the flake I am using to build it

{
  inputs = {
    nixpkgs = {
      url = "nixpkgs/nixos-unstable";
    };
    flake-utils = {
      url = "github:numtide/flake-utils";
    };
  };

  outputs = {self, nixpkgs, flake-utils, ...}:
    flake-utils.lib.eachDefaultSystem(system: 
         let 
            pkgs = nixpkgs.legacyPackages.${system};
            taglib = pkgs.stdenv.mkDerivation {
              name = "taglib";

              nativeBuildInputs = with pkgs; [ pkg-config cmake utf8cpp ];

              src =  pkgs.fetchFromGitHub { 
                owner = "taglib"; 
                repo = "taglib"; 
                rev = "20cec27ac0d9367d98cca0c7b07009f4587e1c6d"; 
                hash = "sha256-YnCd7A9yQvJkH/Kf1M1k1wKB83OymWFqYMEuTEs2CIY="; 
              };
            };

            clipboard = pkgs.stdenv.mkDerivation {
              name = "libclipboard";
              
              nativeBuildInputs = with pkgs; [ pkg-config cmake ];

              buildInputs = with pkgs; [ xorg.libxcb xorg.libXrandr xorg.libXext ];

              src = pkgs.fetchFromGitHub {
                    owner = "jtanx";
                    repo = "libclipboard";
                    rev = "3d2cb08d90a18a9e5010ee0a27c83aa4b4f877a7";
                    hash = "sha256-553hNG8QUlt/Aff9EKYr6w279ELr+2MX7nh1SKIklhA=";
              };
            };

            packages = with pkgs; [
              xcb-util-cursor
              glfw
              cglm
              yt-dlp
              ffmpeg
              jq
              exiftool
              clipboard
              taglib
            ];
         in 
         {
           defaultPackage = pkgs.stdenv.mkDerivation {
             name = "lyssa";

             nativeBuildInputs = [ pkgs.pkg-config ];

             buildInputs = packages;

             src = pkgs.fetchFromGitHub {
               owner = "cococry";
               repo = "lyssa";
               rev = "main";
               hash = "sha256-bKrVprI1rRiEu5n9Ps/iHs8b6Tl7U2HEFqXB8tpruCY=";
             };
           };
         }
    );
}

At the line with packages you use with pkgs doesn’t it then try to call your packages the same way?
Like pkgs.taglib instead of just taglib you can then either just get rid of with pkgs or add your packages to nixpkgs with an overlay, I think.

The other thing, did you test the new derivations on their own first? Are they working?

pkgs.taglib instead of just taglib you can then either just get rid of with pkgs or add your packages to nixpkgs with an overlay, I think.

Taglib isnt part of nixpkgs, as I understood it, it will fallback to the custom derivation.

  • yes, the derivations work on their own

Including the text of the error may help :slight_smile:

1 Like

So far I’ve found that you’re missing another dependency miniaudio it’s already in nixpkgs however.
Edit: so far I haven’t been able to get it to work past this error:

❯ nix build
error: builder for '/nix/store/wds5jd6jkj5hv9xrsxnd5wz6n8rdlciw-lyssa.drv' failed with exit code 2;
       last 10 log lines:
       >  1243 |         system(std::string(LYSSA_DIR + "/scripts/download-yt.sh \"" + currentPlaylist.url + "\" " + LYSSA_DIR + "/downloaded_playlists/ &").c_str());
       >       |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > src/popups.cpp: In member function 'virtual void PlaylistFileDialoguePopup::render()':
       > src/popups.cpp:209:31: warning: ignoring return value of 'int system(const char*)' declared with attribute 'warn_unused_result' [-Wunused-result]
       >   209 |                         system(cmd.c_str());
       >       |                         ~~~~~~^~~~~~~~~~~~~
       > /nix/store/y00xcd5jqq6zlsqs24k8kxw94ppzmmwz-binutils-2.41/bin/ld: skipping incompatible vendor/miniaudio/lib/libminiaudio.a when searching for -lminiaudio
       > /nix/store/y00xcd5jqq6zlsqs24k8kxw94ppzmmwz-binutils-2.41/bin/ld: cannot find -lminiaudio: No such file or directory
       > collect2: error: ld returned 1 exit status
       > make: *** [Makefile:26: build] Error 1
       For full logs, run 'nix log /nix/store/wds5jd6jkj5hv9xrsxnd5wz6n8rdlciw-lyssa.drv'.

My files can be found here, in addition one of your hashes was wrong.

I just realised that this might be because I’m testing it on a Raspberry Pi.
Edit: This is now the error I get on my X86 machine.
I’m not familiar with this but I reckon it’s solvable.
ibxcb.so.1: error adding symbols: DSO missing from command line gives a lot of entries when searching for it.

Error: builder for '/nix/store/yj4x0xnrnsvl6gq7yqy6f3dmaj60cscf-lyssa.drv' failed with exit code 2;
       last 10 log lines:
       >  1243 |         system(std::string(LYSSA_DIR + "/scripts/download-yt.sh \"" + currentPlaylist.url + "\" " + LYSSA_DIR + "/downloaded_playlists/ &").c_str());
       >       |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > src/popups.cpp: In member function 'virtual void PlaylistFileDialoguePopup::render()':
       > src/popups.cpp:209:31: warning: ignoring return value of 'int system(const char*)' declared with attribute 'warn_unused_result' [-Wunused-result]
       >   209 |                         system(cmd.c_str());
       >       |                         ~~~~~~^~~~~~~~~~~~~
       > /nix/store/j2y057vz3i19yh4zjsan1s3q256q15rd-binutils-2.41/bin/ld: /nix/store/6cl1brrq56b121d1ad7h37jjp90vk0fm-libclipboard/lib/libclipboard.a(clipboard_x11.c.o): undefined reference to symbol 'xcb_get_setup'
       > /nix/store/j2y057vz3i19yh4zjsan1s3q256q15rd-binutils-2.41/bin/ld: /nix/store/fy2yyv6xji1bkllx2rwvg6hn0p5s4219-libxcb-1.16/lib/libxcb.so.1: error adding symbols: DSO missing from command line
       > collect2: error: ld returned 1 exit status
       > make: *** [Makefile:26: build] Error 1
       For full logs, run 'nix log /nix/store/yj4x0xnrnsvl6gq7yqy6f3dmaj60cscf-lyssa.drv'.
1 Like

Thanks for checking this out. I am closing this now since the error I am getting is

      |                         ~~~~~~^~~~~~~~~~~~~
/nix/store/j2y057vz3i19yh4zjsan1s3q256q15rd-binutils-2.41/bin/ld: /nix/store/k6p74sax5lnj8hf73k9i6i9r5lcip4y5-clipboard/lib/libclipboard.a(clipboard_x11.c.o): undefined reference to symbol 'xcb_get_setup'
/nix/store/j2y057vz3i19yh4zjsan1s3q256q15rd-binutils-2.41/bin/ld: /nix/store/fy2yyv6xji1bkllx2rwvg6hn0p5s4219-libxcb-1.16/lib/libxcb.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:26: build] Error 1

which at first seemed to me that clipboard’s derivation wasnt getting build, but I have found that this might be a problem of xorg and X server which can be the reason since I am on wayland. Sorry for not including the error in the question and wasting ur time with this one.

Thanks for all the help. I am relatively a newbie to nix and getting such helps was an awesome experience. Thanks

The problem is not because you’re using Wayland.
I’m on Xorg and I’m seeing the same error.

Let’s keep it open, maybe someone knows the solution.
I reckon it’s just something small so that the library gets found.

You’re welcome it helps me to learn as well :slight_smile:

1 Like