1{ stdenv, lib, fetchzip, substituteAll, dpkg, autoPatchelfHook, cups, tcl, tk, xorg, makeWrapper }:
2let
3 debPlatform =
4 if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
5 else if stdenv.hostPlatform.system == "i686-linux" then "i386"
6 else throw "Unsupported system: ${stdenv.hostPlatform.system}";
7in
8stdenv.mkDerivation rec {
9 pname = "fxlinuxprintutil";
10 version = "1.1.1-1";
11
12 # https://support-fb.fujifilm.com/driver_downloads/fxlinuxpdf112119031.zip is gone
13 src = fetchzip {
14 url = "https://github.com/NixOS/nixpkgs/files/12232817/fxlinuxpdf112119031.zip";
15 sha256 = "1mv07ch6ysk9bknfmjqsgxb803sj6vfin29s9knaqv17jvgyh0n3";
16 };
17
18 patches = [
19 # replaces references to “path/to/fxlputil” via $0 that are broken by our wrapProgram
20 # with /nix/store/fxlinuxprintutil/bin/fxlputil
21 ./fxlputil.patch
22
23 # replaces the code that looks for Tcl packages in the working directory and /usr/lib
24 # or /usr/lib64 with /nix/store/fxlinuxprintutil/lib
25 ./fxlputil.tcl.patch
26
27 # replaces the code that looks for X11’s locale.alias in /usr/share/X11/locale or
28 # /usr/lib/X11/locale with /nix/store/libX11/share/X11/locale
29 (substituteAll {
30 src = ./fxlocalechk.tcl.patch;
31 inherit (xorg) libX11;
32 })
33 ];
34
35 nativeBuildInputs = [ dpkg autoPatchelfHook makeWrapper ];
36 buildInputs = [ cups tcl tk ];
37
38 sourceRoot = ".";
39 unpackCmd = "dpkg-deb -x $curSrc/${pname}_${version}_${debPlatform}.deb .";
40
41 dontConfigure = true;
42 dontBuild = true;
43
44 installPhase = ''
45 mkdir -p $out
46 mv usr/bin $out
47 mv usr/lib $out
48
49 wrapProgram $out/bin/fxlputil --prefix PATH : ${lib.makeBinPath [ tcl tk ]}
50 '';
51
52 meta = with lib; {
53 description = "Optional configuration tool for fxlinuxprint";
54 homepage = "https://onlinesupport.fujixerox.com";
55 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
56 license = licenses.unfree;
57 maintainers = with maintainers; [ delan ];
58 platforms = platforms.linux;
59 };
60}