extraPackages for any arbitrary package

Lollypop requires some packages for additional features (kid3) but i don’t wan’t to add it to path, similar to how Neovim’s extraPackages works. Is there a specific method to achieve this?

Thanks in advance

Here’s a small thing I came up with, should work with most packages

{ pkgs, lib }:

  withExtraPackages =
    pkg: extraPackages:
    pkgs.runCommand "${pkg.name}-wrapped" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
      for exe in ${lib.getBin pkg}/bin/*; do
        makeWrapper $exe $out/bin/$(basename $exe) --prefix PATH : ${lib.makeBinPath extraPackages}
  environment.systemPackages = [
    (withExtraPackages pkgs.lollypop [ pkgs.hello ])

Is there a good reason not to add support for the extra features to the package itself? It would probably just look like the already-implemented lastfm support flag.


Note that this may break some packages that depend on paths other than bin/. That could probably be fixed by wrapping the wrapper in a buildEnv with the original package. Though even this may not catch everything as the files in i.e. share/ may reference the unwrapped binary.

The proper solution really is to touch the upstream package as @abathur mentioned. It also means that anyone desiring to use the same additional feature on the package will have an easier time too.


Alright, I think this is the way then. Thanks for all the replies!

1 Like

The merge request fixing this problem: lollypop: 1.4.37 -> 1.4.39 and add kid3 as buildinput by Nydragon · Pull Request #309308 · NixOS/nixpkgs · GitHub