Emacs, EMMS and TagLib

Normally I install Emacs packages using EmacsWithPackages as described in the manual.
However, emms is not enabled with TagLib.

Apparently, there was an EMMS package with TagLib support in nixpkgs, but it has been removed?

My question: how can I make EMMS work with TagLib - the NixOS way?

Created the following file:

# { stdenv, fetchurl }:

{ pkgs ? import <nixpkgs> { }, lib ? import <nixpkgs/lib>, ... }:

pkgs.stdenv.mkDerivation {
  name = "emms-taglib";
  src = pkgs.fetchurl {
    url = "ftp://ftp.gnu.org/gnu/emms/emms-5.4.tar.gz";
    sha256 = "1nd7sb6pva7qb1ki6w0zhd6zvqzd7742kaqi0f3v4as5jh09l6nr";
  };

  buildInputs = [ pkgs.taglib ];
  buildPhase = "make emms-print-metadata";
  installPhase = ''
    mkdir -p $out/bin
    cp src/emms-print-metadata $out/bin
  '';

  meta = with lib; {
    description = "EMMS TagLib shim";
    homepage = "https://www.gnu.org/software/emms/";
    license = licenses.gpl3Plus;
    #   maintainers = with maintainers; [ your-name-here ];
    platforms = platforms.linux ++ platforms.darwin;
  };
}

This works
but it would be nice if this is somehow integrated in emacs-with-packages e.g. when you install epkgs.emms that is will also create the shim

If I try this, I get

trying ftp://ftp.gnu.org/gnu/emms/emms-5.4.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  304k  100  304k    0     0   147k      0  0:00:02  0:00:02 --:--:--  147k
building '/nix/store/s55239fhrg6ginrdz29zbff4sigxy19q-emms-taglib.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/h22224i7p4979zjazqjydd5q42q5wj6p-emms-5.4.tar.gz
source root is emms-5.4
setting SOURCE_DATE_EPOCH to timestamp 1588347484 of file emms-5.4/lisp/emms-auto.el
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
g++    -o src/emms-print-metadata src/emms-print-metadata.cpp `taglib-config --cflags --libs`
/nix/store/7v7g86ml0ri171gfcrs1d442px5bi1p3-binutils-2.41/bin/ld: cannot find -lz: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:39: emms-print-metadata] Error 1
error: builder for '/nix/store/s55239fhrg6ginrdz29zbff4sigxy19q-emms-taglib.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/v306icg9dj4r6hwikrqyfr5hlaa45p5p-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/zp3777i3xlx1l8ab6qig0j6m0375vlrl-nixos-system-quasar-24.05.2310.7dca15289a1c.drv' failed to build
q

I solved this by adding missing dependency zlib to LDFLAGS:

pkgs.stdenv.mkDerivation {
      name = "emms-taglib";
      src = pkgs.fetchurl {
        url = "ftp://ftp.gnu.org/gnu/emms/emms-6.00.tar.gz";
        sha256 = "sha256-awW1pv+BHQyx8BGbn+gxqH3WolKZQWglfNC3u8DbuNo=";
      };

      buildInputs = [ pkgs.taglib ];
      buildPhase = ''
        	LDFLAGS='-L${pkgs.lib.makeLibraryPath [ pkgs.zlib ]}' make emms-print-metadata
      '';
      installPhase = ''
        	mkdir -p $out/bin
                cp src/emms-print-metadata $out/bin
      '';
    }
1 Like