ocamlPackages.magic: 0.7.3 -> 0.7.4, remove myself from maintainer
[NixPkgs.git] / pkgs / by-name / sp / spice-gtk / package.nix
blob5dc9fa557a6b246c45b1128a22db3be2eb21963b
2   lib,
3   stdenv,
4   fetchurl,
5   acl,
6   cyrus_sasl,
7   docbook_xsl,
8   libepoxy,
9   gettext,
10   gobject-introspection,
11   gst_all_1,
12   gtk-doc,
13   gtk3,
14   hwdata,
15   json-glib,
16   libcacard,
17   libcap_ng,
18   libdrm,
19   libjpeg_turbo,
20   libopus,
21   libsoup_3,
22   libusb1,
23   lz4,
24   meson,
25   mesonEmulatorHook,
26   ninja,
27   openssl,
28   perl,
29   phodav,
30   pixman,
31   pkg-config,
32   polkit,
33   python3,
34   spice-protocol,
35   usbredir,
36   vala,
37   wayland-protocols,
38   wayland-scanner,
39   zlib,
40   wrapGAppsHook3,
41   withPolkit ? stdenv.hostPlatform.isLinux,
44 # If this package is built with polkit support (withPolkit=true),
45 # usb redirection requires spice-client-glib-usb-acl-helper to run setuid root.
46 # The helper confirms via polkit that the user has an active session,
47 # then adds a device acl entry for that user.
48 # Example NixOS config to create a setuid wrapper for the helper:
49 # security.wrappers.spice-client-glib-usb-acl-helper.source =
50 #   "${pkgs.spice-gtk}/bin/spice-client-glib-usb-acl-helper";
51 # On non-NixOS installations, make a setuid copy of the helper
52 # outside the store and adjust PATH to find the setuid version.
54 # If this package is built without polkit support (withPolkit=false),
55 # usb redirection requires read-write access to usb devices.
56 # This can be granted by adding users to a custom group like "usb"
57 # and using a udev rule to put all usb devices in that group.
58 # Example NixOS config:
59 #  users.groups.usb = {};
60 #  users.users.dummy.extraGroups = [ "usb" ];
61 #  services.udev.extraRules = ''
62 #    KERNEL=="*", SUBSYSTEMS=="usb", MODE="0664", GROUP="usb"
63 #  '';
65 stdenv.mkDerivation rec {
66   pname = "spice-gtk";
67   version = "0.42";
69   outputs = [
70     "out"
71     "dev"
72     "devdoc"
73     "man"
74   ];
76   src = fetchurl {
77     url = "https://www.spice-space.org/download/gtk/${pname}-${version}.tar.xz";
78     sha256 = "sha256-k4ARfxgRrR+qGBLLZgJHm2KQ1KDYzEQtREJ/f2wOelg=";
79   };
81   depsBuildBuild = [
82     pkg-config
83   ];
85   nativeBuildInputs =
86     [
87       docbook_xsl
88       gettext
89       gobject-introspection
90       gtk-doc
91       meson
92       ninja
93       perl
94       pkg-config
95       python3
96       python3.pkgs.pyparsing
97       python3.pkgs.six
98       vala
99       wrapGAppsHook3
100     ]
101     ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
102       mesonEmulatorHook
103     ]
104     ++ lib.optionals stdenv.hostPlatform.isLinux [
105       wayland-scanner
106     ];
108   buildInputs =
109     [
110       gst_all_1.gst-plugins-base
111       gst_all_1.gst-plugins-good
112       cyrus_sasl
113       libepoxy
114       gtk3
115       json-glib
116       libcacard
117       libjpeg_turbo
118       libopus
119       libsoup_3
120       libusb1
121       lz4
122       openssl
123       phodav
124       pixman
125       spice-protocol
126       usbredir
127       vala
128       zlib
129     ]
130     ++ lib.optionals withPolkit [
131       polkit
132       acl
133     ]
134     ++ lib.optionals stdenv.hostPlatform.isLinux [
135       libcap_ng
136       libdrm
137       wayland-protocols
138     ];
140   PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "${placeholder "out"}/share/polkit-1/actions";
142   mesonFlags =
143     [
144       "-Dusb-acl-helper-dir=${placeholder "out"}/bin"
145       "-Dusb-ids-path=${hwdata}/share/hwdata/usb.ids"
146     ]
147     ++ lib.optionals (!withPolkit) [
148       "-Dpolkit=disabled"
149     ]
150     ++ lib.optionals (!stdenv.hostPlatform.isLinux) [
151       "-Dlibcap-ng=disabled"
152       "-Degl=disabled"
153     ]
154     ++ lib.optionals stdenv.hostPlatform.isMusl [
155       "-Dcoroutine=gthread" # Fixes "Function missing:makecontext"
156     ];
158   postPatch =
159     ''
160       # get rid of absolute path to helper in store so we can use a setuid wrapper
161       substituteInPlace src/usb-acl-helper.c \
162         --replace-fail 'ACL_HELPER_PATH"/' '"'
163       # don't try to setcap/suid in a nix builder
164       substituteInPlace src/meson.build \
165         --replace-fail "meson.add_install_script('../build-aux/setcap-or-suid'," \
166         "# meson.add_install_script('../build-aux/setcap-or-suid',"
168       patchShebangs subprojects/keycodemapdb/tools/keymap-gen
169     ''
170     + lib.optionalString stdenv.hostPlatform.isDarwin ''
171       # don't use version script and don't export symbols
172       substituteInPlace src/meson.build \
173         --replace-fail "spice_gtk_version_script = [" "# spice_gtk_version_script = [" \
174         --replace-fail ",--version-script=@0@'.format(spice_client_glib_syms_path)" "'"
175     '';
177   meta = with lib; {
178     description = "GTK 3 SPICE widget";
179     longDescription = ''
180       spice-gtk is a GTK 3 SPICE widget. It features glib-based
181       objects for SPICE protocol parsing and a gtk widget for embedding
182       the SPICE display into other applications such as virt-manager.
183       Python bindings are available too.
184     '';
186     homepage = "https://www.spice-space.org/";
187     license = licenses.lgpl21;
188     maintainers = [ maintainers.xeji ];
189     platforms = platforms.unix;
190   };