{ lib , stdenv , fetchurl , dpkg , autoPatchelfHook , cups }: stdenv.mkDerivation rec { pname = "rollo-cups-driver"; version = "1.8.4-1"; src = fetchurl { url = "https://rollo-main.b-cdn.net/driver-dl/linux/rollo-cups-driver_${version}_amd64.deb"; # Rollo's CDN gates the download on a Referer header, so we have to pass # it through fetchurl's underlying curl call. curlOptsList = [ "-H" "Referer: https://www.rollo.com/driver-linux/" ]; hash = "sha256-01SKxC5qPdfpMqsCR6UuogmvbrYwF7BI+C1ptURfNko="; # replace after first build, see notes below }; nativeBuildInputs = [ dpkg autoPatchelfHook ]; buildInputs = [ stdenv.cc.cc.lib cups ]; unpackPhase = '' runHook preUnpack dpkg-deb -x $src debroot runHook postUnpack ''; dontBuild = true; installPhase = '' runHook preInstall mkdir -p $out/lib/cups/filter mkdir -p $out/share/cups/model # Layout inside the .deb has moved around between Rollo releases, so # grab anything that looks like the filter binary or a PPD rather than # hardcoding one path. find debroot -type f \( -iname 'rastertorollo*' -o -iname 'rastertolabel*' \) \ -exec install -m755 {} $out/lib/cups/filter/ \; find debroot -type f -iname '*.ppd' \ -exec install -m644 {} $out/share/cups/model/ \; runHook postInstall ''; # autoPatchelfHook rewrites the ELF interpreter/rpath to point at # $buildInputs in the Nix store instead of /lib64/ld-linux-x86-64.so.2 # and the FHS lib paths the binary was linked against. meta = with lib; { description = "Rollo/Beeprt/JADENS proprietary CUPS raster filter for TSPL thermal label printers"; homepage = "https://www.rollo.com/driver-linux/"; license = licenses.unfree; platforms = [ "x86_64-linux" ]; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; }; }