nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchzip,
6 libX11,
7 libXt,
8 autoreconfHook,
9 quilt,
10
11 libjpeg ? null,
12 libpng ? null,
13 libtiff ? null,
14
15 withJpegSupport ? true,
16 withPngSupport ? true,
17 withTiffSupport ? true,
18}:
19
20assert withJpegSupport -> libjpeg != null;
21assert withPngSupport -> libpng != null;
22assert withTiffSupport -> libtiff != null;
23
24let
25 version = "4.1";
26 deb_patch = "25";
27 debian_patches = fetchzip {
28 url = "mirror://debian/pool/main/x/xloadimage/xloadimage_${version}-${deb_patch}.debian.tar.xz";
29 hash = "sha256-5FbkiYjI8ASUyi1DTFiAcJ9y2z1sEKrNNyKoqnca30I=";
30 };
31in
32stdenv.mkDerivation rec {
33 pname = "xloadimage";
34 inherit version;
35
36 src = fetchurl {
37 url = "mirror://debian/pool/main/x/xloadimage/xloadimage_${version}.orig.tar.gz";
38 sha256 = "1i7miyvk5ydhi6yi8593vapavhwxcwciir8wg9d2dcyg9pccf2s0";
39 };
40
41 postPatch = ''
42 QUILT_PATCHES=${debian_patches}/patches quilt push -a
43 '';
44
45 nativeBuildInputs = [
46 autoreconfHook
47 quilt
48 ];
49
50 buildInputs = [
51 libX11
52 libXt
53 ]
54 ++ lib.optionals withJpegSupport [
55 libjpeg
56 ]
57 ++ lib.optionals withPngSupport [
58 libpng
59 ]
60 ++ lib.optionals withTiffSupport [
61 libtiff
62 ];
63
64 # NOTE: we patch the build-info script so that it never detects the utilities
65 # it's trying to find; one of the Debian patches adds support for
66 # $SOURCE_DATE_EPOCH, but we want to make sure we don't even call these.
67 preConfigure = ''
68 substituteInPlace build-info \
69 --replace-fail '[ -x /bin/date ]' 'false' \
70 --replace-fail '[ -x /bin/id ]' 'false' \
71 --replace-fail '[ -x /bin/uname ]' 'false' \
72 --replace-fail '[ -x /usr/bin/id ]' 'false'
73
74 chmod +x build-info configure
75 '';
76
77 enableParallelBuilding = true;
78
79 # creating patch would add more complexity
80 env.CFLAGS = "-Wno-implicit-int";
81
82 # NOTE: we're not installing the `uufilter` binary; if needed, the standard
83 # `uudecode` tool should work just fine.
84 installPhase = ''
85 install -Dm755 xloadimage $out/bin/xloadimage
86 ln -sv $out/bin/{xloadimage,xsetbg}
87
88 install -D -m644 xloadimagerc $out/etc/xloadimagerc.example
89 install -D -m644 xloadimage.man $out/share/man/man1/xloadimage.1x
90 ln -sv $out/share/man/man1/{xloadimage,xsetbg}.1x
91 '';
92
93 meta = {
94 description = "Graphics file viewer under X11";
95
96 longDescription = ''
97 Can view png, jpeg, gif, tiff, niff, sunraster, fbm, cmuraster, pbm,
98 faces, rle, xwd, vff, mcidas, vicar, pcx, gem, macpaint, xpm and xbm
99 files. Can view images, put them on the root window, or dump them. Does a
100 variety of processing, including: clipping, dithering, depth reduction,
101 zoom, brightening/darkening and merging.
102 '';
103
104 license = lib.licenses.gpl2Plus;
105
106 maintainers = [ ];
107 platforms = lib.platforms.linux; # arbitrary choice
108 };
109}