1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 sane-backends,
6 sane-frontends,
7 libX11,
8 gtk2,
9 pkg-config,
10 libpng,
11 libusb-compat-0_1,
12 gimpSupport ? false,
13 gimp,
14 nix-update-script,
15 fetchpatch,
16}:
17
18stdenv.mkDerivation rec {
19 pname = "xsane";
20 version = "0.999";
21
22 src = fetchFromGitLab {
23 owner = "frontend";
24 group = "sane-project";
25 repo = pname;
26 rev = version;
27 hash = "sha256-oOg94nUsT9LLKnHocY0S5g02Y9a1UazzZAjpEI/s+yM=";
28 };
29
30 # add all fedora patchs. fix gcc-14 build among other things
31 # https://src.fedoraproject.org/rpms/xsane/tree/main
32 patches =
33 let
34 fetchFedoraPatch =
35 { name, hash }:
36 fetchpatch {
37 inherit name hash;
38 url = "https://src.fedoraproject.org/rpms/xsane/raw/846ace0a29063335c708b01e9696eda062d7459c/f/${name}";
39 };
40 in
41 map fetchFedoraPatch [
42 {
43 name = "0001-Follow-new-convention-for-registering-gimp-plugin.patch";
44 hash = "sha256-yOY7URyc8HEHHynvdcZAV1Pri31N/rJ0ddPavOF5zLw=";
45 }
46 {
47 name = "xsane-0.995-close-fds.patch";
48 hash = "sha256-qE7larHpBEikz6OaOQmmi9jl6iQxy/QM7iDg9QrVV1o=";
49 }
50 {
51 name = "xsane-0.995-xdg-open.patch";
52 hash = "sha256-/kHwwuDC2naGEp4NALfaJ0pJe+9kYhV4TX1eGeARvq8=";
53 }
54 {
55 name = "xsane-0.996-no-eula.patch";
56 hash = "sha256-CYmp1zFg11PUPz9um2W7XF6pzCzafKSEn2nvPiUSxNo=";
57 }
58 {
59 name = "xsane-0.997-ipv6.patch";
60 hash = "sha256-D3xH++DHxyTKMxgatU+PNCVN1u5ajPc3gQxvzhMYIdM=";
61 }
62 {
63 name = "xsane-0.997-off-root-build.patch";
64 hash = "sha256-2LXQfMbvqP+TAhAmxRe6pBqNlSX4tVjhDkBHIfX9HcA=";
65 }
66 {
67 name = "xsane-0.998-desktop-file.patch";
68 hash = "sha256-3xEj6IaOk/FS8pv+/yaNjZpIoB+0Oei0QB9mD4/owkM=";
69 }
70 {
71 name = "xsane-0.998-libpng.patch";
72 hash = "sha256-0z292+Waa2g0PCQpUebdWprl9VDyBOY0XgqMJaIcRb8=";
73 }
74 {
75 name = "xsane-0.998-preview-selection.patch";
76 hash = "sha256-TZ8vRA+0qPY2Rqz0VNHjgkj3YPob/BW+zBoVqxnUhb8=";
77 }
78 {
79 name = "xsane-0.998-wmclass.patch";
80 hash = "sha256-RubFOs+hsZS+GdxF0yvLSy4v+Fi6vb9G6zfwWZcUlkY=";
81 }
82 {
83 name = "xsane-0.999-lcms2.patch";
84 hash = "sha256-eiAxa1lhFrinqBvlIhH+NP7WBKk0Plf2S+OVTcpxXac=";
85 }
86 {
87 name = "xsane-0.999-man-page.patch";
88 hash = "sha256-4g0w4x9boAIOA6s5eTzKMh2mkkRKtF1TZ9KgHNTDaAg=";
89 }
90 {
91 name = "xsane-0.999-no-file-selected.patch";
92 hash = "sha256-e/QKtvsIwU5yy0SJKAEAmhmCoxWqV6FHmAW41SbW/eI=";
93 }
94 {
95 name = "xsane-0.999-pdf-no-high-bpp.patch";
96 hash = "sha256-o3LmOvgERuB9CQ8RL2Nd40h1ePuuuGMSK1GN68QlJ6s=";
97 }
98 {
99 name = "xsane-0.999-signal-handling.patch";
100 hash = "sha256-JU9BJ6UIDa1FsuPaQKsxcjxvsJkwgmuopIqCVWY3LQ0=";
101 }
102 {
103 name = "xsane-0.999-snprintf-update.patch";
104 hash = "sha256-bSTeoIOLeJ4PEsBHR+ZUQLPmrc0D6aQzyJGlLVhXt8o=";
105 }
106 {
107 name = "xsane-configure-c99.patch";
108 hash = "sha256-ukaNGgzCGiQwbOzSguAqBIKOUzXofSC3lct812U/8gY=";
109 }
110 ];
111
112 preConfigure = ''
113 sed -e '/SANE_CAP_ALWAYS_SETTABLE/d' -i src/xsane-back-gtk.c
114 chmod a+rX -R .
115 '';
116
117 nativeBuildInputs = [ pkg-config ];
118
119 buildInputs = [
120 libpng
121 libusb-compat-0_1
122 sane-backends
123 sane-frontends
124 libX11
125 gtk2
126 ]
127 ++ lib.optional gimpSupport gimp;
128
129 passthru.updateScript = nix-update-script { };
130
131 meta = with lib; {
132 homepage = "http://www.sane-project.org/";
133 description = "Graphical scanning frontend for sane";
134 mainProgram = "xsane";
135 license = licenses.gpl2Plus;
136 platforms = platforms.linux;
137 maintainers = with maintainers; [ melling ];
138 };
139}