croc: 10.1.1 -> 10.1.3 (#364662)
[NixPkgs.git] / pkgs / servers / mir / common.nix
blob4041ae7cf087e4f5294fd8eee065e7074cbea0b1
2   stdenv,
3   lib,
4   fetchFromGitHub,
5   nixosTests,
6   testers,
7   cmake,
8   pkg-config,
9   python3,
10   boost,
11   egl-wayland,
12   freetype,
13   glib,
14   glm,
15   glog,
16   libapparmor,
17   libdrm,
18   libepoxy,
19   libevdev,
20   libglvnd,
21   libinput,
22   libuuid,
23   libxcb,
24   libxkbcommon,
25   libxmlxx,
26   yaml-cpp,
27   lttng-ust,
28   mesa,
29   nettle,
30   udev,
31   wayland,
32   wayland-scanner,
33   xorg,
34   xwayland,
35   dbus,
36   gobject-introspection,
37   gtest,
38   umockdev,
39   wlcs,
40   validatePkgConfig,
44   version,
45   pinned ? false,
46   hash,
47   patches ? [ ],
50 stdenv.mkDerivation (finalAttrs: {
51   pname = "mir";
52   inherit version;
54   src = fetchFromGitHub {
55     owner = "canonical";
56     repo = "mir";
57     rev = "v${finalAttrs.version}";
58     inherit hash;
59   };
61   inherit patches;
63   postPatch =
64     ''
65       # Fix scripts that get run in tests
66       patchShebangs tools/detect_fd_leaks.bash tests/acceptance-tests/wayland-generator/test_wayland_generator.sh.in
68       # Fix LD_PRELOADing in tests
69       substituteInPlace \
70         cmake/MirCommon.cmake \
71         tests/umock-acceptance-tests/CMakeLists.txt \
72         tests/unit-tests/platforms/gbm-kms/kms/CMakeLists.txt \
73         tests/unit-tests/CMakeLists.txt \
74         --replace-warn 'LD_PRELOAD=liblttng-ust-fork.so' 'LD_PRELOAD=${lib.getLib lttng-ust}/lib/liblttng-ust-fork.so' \
75         --replace-warn 'LD_PRELOAD=libumockdev-preload.so.0' 'LD_PRELOAD=${lib.getLib umockdev}/lib/libumockdev-preload.so.0'
77       # Fix Xwayland default
78       substituteInPlace src/miral/x11_support.cpp \
79         --replace-fail '/usr/bin/Xwayland' '${lib.getExe xwayland}'
80     ''
81     + lib.optionalString (lib.strings.versionOlder version "2.18.0") ''
83       # Fix paths for generating drm-formats
84       substituteInPlace src/platform/graphics/CMakeLists.txt \
85         --replace-fail "/usr/include/drm/drm_fourcc.h" "${lib.getDev libdrm}/include/libdrm/drm_fourcc.h" \
86         --replace-fail "/usr/include/libdrm/drm_fourcc.h" "${lib.getDev libdrm}/include/libdrm/drm_fourcc.h"
87     '';
89   strictDeps = true;
91   nativeBuildInputs = [
92     cmake
93     glib # gdbus-codegen
94     lttng-ust # lttng-gen-tp
95     pkg-config
96     (python3.withPackages (
97       ps:
98       with ps;
99       [ pillow ]
100       ++ lib.optionals finalAttrs.finalPackage.doCheck [
101         pygobject3
102         python-dbusmock
103       ]
104     ))
105     validatePkgConfig
106     wayland-scanner
107   ];
109   buildInputs = [
110     boost
111     egl-wayland
112     freetype
113     glib
114     glm
115     glog
116     libdrm
117     libepoxy
118     libevdev
119     libglvnd
120     libinput
121     libuuid
122     libxcb
123     libxkbcommon
124     libxmlxx
125     yaml-cpp
126     lttng-ust
127     mesa
128     nettle
129     udev
130     wayland
131     xorg.libX11
132     xorg.libXcursor
133     xorg.xorgproto
134     xwayland
135   ] ++ lib.optionals (lib.strings.versionAtLeast version "2.18.0") [ libapparmor ];
137   nativeCheckInputs = [
138     dbus
139     gobject-introspection
140   ];
142   checkInputs = [
143     gtest
144     umockdev
145     wlcs
146   ];
148   cmakeFlags = [
149     (lib.cmakeBool "BUILD_DOXYGEN" false)
150     (lib.cmakeFeature "MIR_PLATFORM" (
151       lib.strings.concatStringsSep ";" [
152         "gbm-kms"
153         "x11"
154         "eglstream-kms"
155         "wayland"
156       ]
157     ))
158     (lib.cmakeBool "MIR_ENABLE_TESTS" finalAttrs.finalPackage.doCheck)
159     # BadBufferTest.test_truncated_shm_file *doesn't* throw an error as the test expected, mark as such
160     # https://github.com/canonical/mir/pull/1947#issuecomment-811810872
161     (lib.cmakeBool "MIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN" true)
162     (lib.cmakeFeature "MIR_EXCLUDE_TESTS" (lib.strings.concatStringsSep ";" [ ]))
163     # These get built but don't get executed by default, yet they get installed when tests are enabled
164     (lib.cmakeBool "MIR_BUILD_PERFORMANCE_TESTS" false)
165     (lib.cmakeBool "MIR_BUILD_PLATFORM_TEST_HARNESS" false)
166     # https://github.com/canonical/mir/issues/2987
167     # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799
168     (lib.cmakeBool "MIR_USE_PRECOMPILED_HEADERS" false)
169     (lib.cmakeFeature "MIR_COMPILER_QUIRKS" (
170       lib.strings.concatStringsSep ";" [
171         # https://github.com/canonical/mir/issues/3017 actually affects x86_64 as well
172         "test_touchspot_controller.cpp:array-bounds"
173       ]
174     ))
175   ];
177   doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
179   preCheck = ''
180     export XDG_RUNTIME_DIR=$TMP
181   '';
183   outputs = [
184     "out"
185     "dev"
186   ];
188   passthru = {
189     tests = {
190       pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
191     } // lib.optionalAttrs (!pinned) { inherit (nixosTests) miriway miracle-wm; };
192     providedSessions = lib.optionals (lib.strings.versionOlder version "2.16.0") [
193       # More of an example than a fully functioning shell, some notes for the adventurous:
194       # - ~/.config/miral-shell.config is one possible user config location,
195       #   accepted options=value are according to `mir-shell --help`
196       # - default icon theme setting is DMZ-White, needs vanilla-dmz installed & on XCURSOR_PATH
197       #   or setting to be changed to an available theme
198       # - terminal emulator setting may need to be changed if miral-terminal script
199       #   does not know about preferred terminal
200       "mir-shell"
201     ];
202   } // lib.optionalAttrs (!pinned) { updateScript = ./update.sh; };
204   meta = {
205     description = "Display server and Wayland compositor developed by Canonical";
206     homepage = "https://mir-server.io";
207     changelog = "https://github.com/canonical/mir/releases/tag/v${finalAttrs.version}";
208     license = lib.licenses.gpl2Plus;
209     maintainers = with lib.maintainers; [
210       onny
211       OPNA2608
212     ];
213     platforms = lib.platforms.linux;
214     pkgConfigModules =
215       [
216         "miral"
217         "mircommon"
218         "mircore"
219         "miroil"
220         "mirplatform"
221         "mir-renderer-gl-dev"
222         "mirrenderer"
223         "mirserver"
224         "mirtest"
225         "mirwayland"
226       ]
227       ++ lib.optionals (lib.strings.versionOlder version "2.17.0") [ "mircookie" ]
228       ++ lib.optionals (lib.strings.versionAtLeast version "2.17.0") [
229         "mircommon-internal"
230         "mirserver-internal"
231       ];
232   };