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