From 245aee34d95b7a03619d0b7ef42a179b1b7e8de0 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Sun, 9 Jun 2024 14:47:21 +0200 Subject: [PATCH] mir_2_15: init at 2.15.0 --- .../lomiri/applications/lomiri/default.nix | 4 +- .../lomiri/development/qtmir/default.nix | 4 +- pkgs/servers/mir/common.nix | 227 ++++++++++++++++++ pkgs/servers/mir/default.nix | 226 +++-------------- pkgs/servers/mir/update.sh | 8 + pkgs/top-level/all-packages.nix | 4 +- 6 files changed, 269 insertions(+), 204 deletions(-) create mode 100644 pkgs/servers/mir/common.nix create mode 100755 pkgs/servers/mir/update.sh diff --git a/pkgs/desktops/lomiri/applications/lomiri/default.nix b/pkgs/desktops/lomiri/applications/lomiri/default.nix index ca46560e702a..d628da0746fa 100644 --- a/pkgs/desktops/lomiri/applications/lomiri/default.nix +++ b/pkgs/desktops/lomiri/applications/lomiri/default.nix @@ -40,7 +40,7 @@ , lomiri-notifications , lomiri-thumbnailer , maliit-keyboard -, mir +, mir_2_15 , nixos-icons , pam , pkg-config @@ -191,7 +191,7 @@ stdenv.mkDerivation (finalAttrs: { lomiri-system-settings-unwrapped lomiri-ui-toolkit maliit-keyboard - mir + mir_2_15 pam properties-cpp protobuf diff --git a/pkgs/desktops/lomiri/development/qtmir/default.nix b/pkgs/desktops/lomiri/development/qtmir/default.nix index ba49507f3d36..654fd93fc59b 100644 --- a/pkgs/desktops/lomiri/development/qtmir/default.nix +++ b/pkgs/desktops/lomiri/development/qtmir/default.nix @@ -16,7 +16,7 @@ , lomiri-app-launch , lomiri-url-dispatcher , lttng-ust -, mir +, mir_2_15 , process-cpp , qtbase , qtdeclarative @@ -109,7 +109,7 @@ stdenv.mkDerivation (finalAttrs: { lomiri-app-launch lomiri-url-dispatcher lttng-ust - mir + mir_2_15 process-cpp protobuf qtbase diff --git a/pkgs/servers/mir/common.nix b/pkgs/servers/mir/common.nix new file mode 100644 index 000000000000..bc81972e30b2 --- /dev/null +++ b/pkgs/servers/mir/common.nix @@ -0,0 +1,227 @@ +{ + stdenv, + lib, + fetchFromGitHub, + testers, + cmake, + pkg-config, + python3, + boost, + egl-wayland, + freetype, + glib, + glm, + glog, + libdrm, + libepoxy, + libevdev, + libglvnd, + libinput, + libuuid, + libxcb, + libxkbcommon, + libxmlxx, + yaml-cpp, + lttng-ust, + mesa, + nettle, + udev, + wayland, + wayland-scanner, + xorg, + xwayland, + dbus, + gobject-introspection, + gtest, + umockdev, + wlcs, + validatePkgConfig, +}: + +{ + version, + pinned ? false, + hash, + patches ? [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "mir"; + inherit version; + + src = fetchFromGitHub { + owner = "canonical"; + repo = "mir"; + rev = "v${finalAttrs.version}"; + inherit hash; + }; + + inherit patches; + + postPatch = '' + # Fix scripts that get run in tests + patchShebangs tools/detect_fd_leaks.bash tests/acceptance-tests/wayland-generator/test_wayland_generator.sh.in + + # Fix LD_PRELOADing in tests + substituteInPlace \ + cmake/MirCommon.cmake \ + tests/umock-acceptance-tests/CMakeLists.txt \ + tests/unit-tests/platforms/gbm-kms/kms/CMakeLists.txt \ + tests/unit-tests/CMakeLists.txt \ + --replace-warn 'LD_PRELOAD=liblttng-ust-fork.so' 'LD_PRELOAD=${lib.getLib lttng-ust}/lib/liblttng-ust-fork.so' \ + --replace-warn 'LD_PRELOAD=libumockdev-preload.so.0' 'LD_PRELOAD=${lib.getLib umockdev}/lib/libumockdev-preload.so.0' + + # Fix Xwayland default + substituteInPlace src/miral/x11_support.cpp \ + --replace-fail '/usr/bin/Xwayland' '${lib.getExe xwayland}' + + # Fix paths for generating drm-formats + substituteInPlace src/platform/graphics/CMakeLists.txt \ + --replace-fail "/usr/include/drm/drm_fourcc.h" "${lib.getDev libdrm}/include/libdrm/drm_fourcc.h" \ + --replace-fail "/usr/include/libdrm/drm_fourcc.h" "${lib.getDev libdrm}/include/libdrm/drm_fourcc.h" + ''; + + strictDeps = true; + + nativeBuildInputs = [ + cmake + glib # gdbus-codegen + lttng-ust # lttng-gen-tp + pkg-config + (python3.withPackages ( + ps: + with ps; + [ pillow ] + ++ lib.optionals finalAttrs.finalPackage.doCheck [ + pygobject3 + python-dbusmock + ] + )) + validatePkgConfig + wayland-scanner + ]; + + buildInputs = [ + boost + egl-wayland + freetype + glib + glm + glog + libdrm + libepoxy + libevdev + libglvnd + libinput + libuuid + libxcb + libxkbcommon + libxmlxx + yaml-cpp + lttng-ust + mesa + nettle + udev + wayland + xorg.libX11 + xorg.libXcursor + xorg.xorgproto + xwayland + ]; + + nativeCheckInputs = [ + dbus + gobject-introspection + ]; + + checkInputs = [ + gtest + umockdev + wlcs + ]; + + cmakeFlags = [ + (lib.cmakeBool "BUILD_DOXYGEN" false) + (lib.cmakeFeature "MIR_PLATFORM" ( + lib.strings.concatStringsSep ";" [ + "gbm-kms" + "x11" + "eglstream-kms" + "wayland" + ] + )) + (lib.cmakeBool "MIR_ENABLE_TESTS" finalAttrs.finalPackage.doCheck) + # BadBufferTest.test_truncated_shm_file *doesn't* throw an error as the test expected, mark as such + # https://github.com/canonical/mir/pull/1947#issuecomment-811810872 + (lib.cmakeBool "MIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN" true) + (lib.cmakeFeature "MIR_EXCLUDE_TESTS" (lib.strings.concatStringsSep ";" [ ])) + # These get built but don't get executed by default, yet they get installed when tests are enabled + (lib.cmakeBool "MIR_BUILD_PERFORMANCE_TESTS" false) + (lib.cmakeBool "MIR_BUILD_PLATFORM_TEST_HARNESS" false) + # https://github.com/canonical/mir/issues/2987 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799 + (lib.cmakeBool "MIR_USE_PRECOMPILED_HEADERS" false) + (lib.cmakeFeature "MIR_COMPILER_QUIRKS" ( + lib.strings.concatStringsSep ";" [ + # https://github.com/canonical/mir/issues/3017 actually affects x86_64 as well + "test_touchspot_controller.cpp:array-bounds" + ] + )) + ]; + + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + + preCheck = '' + export XDG_RUNTIME_DIR=$TMP + ''; + + outputs = [ + "out" + "dev" + ]; + + passthru = { + tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + providedSessions = lib.optionals (lib.strings.versionOlder version "2.16.0") [ + # More of an example than a fully functioning shell, some notes for the adventurous: + # - ~/.config/miral-shell.config is one possible user config location, + # accepted options=value are according to `mir-shell --help` + # - default icon theme setting is DMZ-White, needs vanilla-dmz installed & on XCURSOR_PATH + # or setting to be changed to an available theme + # - terminal emulator setting may need to be changed if miral-terminal script + # does not know about preferred terminal + "mir-shell" + ]; + } // lib.optionalAttrs (!pinned) { + updateScript = ./update.sh; + }; + + meta = with lib; { + description = "A display server and Wayland compositor developed by Canonical"; + homepage = "https://mir-server.io"; + changelog = "https://github.com/canonical/mir/releases/tag/v${finalAttrs.version}"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ + onny + OPNA2608 + ]; + platforms = platforms.linux; + pkgConfigModules = [ + "miral" + "mircommon" + "mircore" + "miroil" + "mirplatform" + "mir-renderer-gl-dev" + "mirrenderer" + "mirserver" + "mirtest" + "mirwayland" + ] ++ lib.optionals (lib.strings.versionOlder version "2.17.0") [ + "mircookie" + ] ++ lib.optionals (lib.strings.versionAtLeast version "2.17.0") [ + "mircommon-internal" + "mirserver-internal" + ]; + }; +}) diff --git a/pkgs/servers/mir/default.nix b/pkgs/servers/mir/default.nix index 743bf92b7609..b61419eacf47 100644 --- a/pkgs/servers/mir/default.nix +++ b/pkgs/servers/mir/default.nix @@ -1,205 +1,33 @@ +{ callPackage, fetchpatch }: + +let + common = callPackage ./common.nix { }; +in { - stdenv, - lib, - fetchFromGitHub, - gitUpdater, - testers, - cmake, - pkg-config, - python3, - boost, - egl-wayland, - freetype, - glib, - glm, - glog, - libdrm, - libepoxy, - libevdev, - libglvnd, - libinput, - libuuid, - libxcb, - libxkbcommon, - libxmlxx, - yaml-cpp, - lttng-ust, - mesa, - nettle, - udev, - wayland, - wayland-scanner, - xorg, - xwayland, - dbus, - gobject-introspection, - gtest, - umockdev, - wlcs, - validatePkgConfig, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "mir"; - version = "2.17.0"; - - src = fetchFromGitHub { - owner = "canonical"; - repo = "mir"; - rev = "v${finalAttrs.version}"; + mir = common { + version = "2.17.0"; hash = "sha256-iDJ7NIFoSSXjMrHK2I6Linf7z0hvShj8fr6BGxgK5gE="; }; - postPatch = '' - # Fix scripts that get run in tests - patchShebangs tools/detect_fd_leaks.bash tests/acceptance-tests/wayland-generator/test_wayland_generator.sh.in - - # Fix LD_PRELOADing in tests - substituteInPlace \ - cmake/MirCommon.cmake \ - tests/umock-acceptance-tests/CMakeLists.txt \ - tests/unit-tests/platforms/gbm-kms/kms/CMakeLists.txt \ - tests/unit-tests/CMakeLists.txt \ - --replace-warn 'LD_PRELOAD=liblttng-ust-fork.so' 'LD_PRELOAD=${lib.getLib lttng-ust}/lib/liblttng-ust-fork.so' \ - --replace-warn 'LD_PRELOAD=libumockdev-preload.so.0' 'LD_PRELOAD=${lib.getLib umockdev}/lib/libumockdev-preload.so.0' - - # Fix Xwayland default - substituteInPlace src/miral/x11_support.cpp \ - --replace-fail '/usr/bin/Xwayland' '${lib.getExe xwayland}' - - # Fix paths for generating drm-formats - substituteInPlace src/platform/graphics/CMakeLists.txt \ - --replace-fail "/usr/include/drm/drm_fourcc.h" "${lib.getDev libdrm}/include/libdrm/drm_fourcc.h" \ - --replace-fail "/usr/include/libdrm/drm_fourcc.h" "${lib.getDev libdrm}/include/libdrm/drm_fourcc.h" - ''; - - strictDeps = true; - - nativeBuildInputs = [ - cmake - glib # gdbus-codegen - lttng-ust # lttng-gen-tp - pkg-config - (python3.withPackages ( - ps: - with ps; - [ pillow ] - ++ lib.optionals finalAttrs.finalPackage.doCheck [ - pygobject3 - python-dbusmock - ] - )) - validatePkgConfig - wayland-scanner - ]; - - buildInputs = [ - boost - egl-wayland - freetype - glib - glm - glog - libdrm - libepoxy - libevdev - libglvnd - libinput - libuuid - libxcb - libxkbcommon - libxmlxx - yaml-cpp - lttng-ust - mesa - nettle - udev - wayland - xorg.libX11 - xorg.libXcursor - xorg.xorgproto - xwayland - ]; - - nativeCheckInputs = [ - dbus - gobject-introspection - ]; - - checkInputs = [ - gtest - umockdev - wlcs - ]; - - cmakeFlags = [ - (lib.cmakeBool "BUILD_DOXYGEN" false) - (lib.cmakeFeature "MIR_PLATFORM" ( - lib.strings.concatStringsSep ";" [ - "gbm-kms" - "x11" - "eglstream-kms" - "wayland" - ] - )) - (lib.cmakeBool "MIR_ENABLE_TESTS" finalAttrs.finalPackage.doCheck) - # BadBufferTest.test_truncated_shm_file *doesn't* throw an error as the test expected, mark as such - # https://github.com/canonical/mir/pull/1947#issuecomment-811810872 - (lib.cmakeBool "MIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN" true) - (lib.cmakeFeature "MIR_EXCLUDE_TESTS" (lib.strings.concatStringsSep ";" [ ])) - # These get built but don't get executed by default, yet they get installed when tests are enabled - (lib.cmakeBool "MIR_BUILD_PERFORMANCE_TESTS" false) - (lib.cmakeBool "MIR_BUILD_PLATFORM_TEST_HARNESS" false) - # https://github.com/canonical/mir/issues/2987 - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799 - (lib.cmakeBool "MIR_USE_PRECOMPILED_HEADERS" false) - (lib.cmakeFeature "MIR_COMPILER_QUIRKS" ( - lib.strings.concatStringsSep ";" [ - # https://github.com/canonical/mir/issues/3017 actually affects x86_64 as well - "test_touchspot_controller.cpp:array-bounds" - ] - )) - ]; - - doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; - - preCheck = '' - export XDG_RUNTIME_DIR=$TMP - ''; - - outputs = [ - "out" - "dev" - ]; - - passthru = { - tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; - updateScript = gitUpdater { rev-prefix = "v"; }; - }; - - meta = with lib; { - description = "A display server and Wayland compositor developed by Canonical"; - homepage = "https://mir-server.io"; - changelog = "https://github.com/canonical/mir/releases/tag/v${finalAttrs.version}"; - license = licenses.gpl2Plus; - maintainers = with maintainers; [ - onny - OPNA2608 - ]; - platforms = platforms.linux; - pkgConfigModules = [ - "miral" - "mircommon" - "mircommon-internal" - "mircore" - "miroil" - "mirplatform" - "mir-renderer-gl-dev" - "mirrenderer" - "mirserver" - "mirserver-internal" - "mirtest" - "mirwayland" + mir_2_15 = common { + version = "2.15.0"; + pinned = true; + hash = "sha256-c1+gxzLEtNCjR/mx76O5QElQ8+AO4WsfcG7Wy1+nC6E="; + patches = [ + # Fix gbm-kms tests + # Remove when version > 2.15.0 + (fetchpatch { + name = "0001-mir-Fix-the-signature-of-drmModeCrtcSetGamma.patch"; + url = "https://github.com/canonical/mir/commit/98250e9c32c5b9b940da2fb0a32d8139bbc68157.patch"; + hash = "sha256-tTtOHGNue5rsppOIQSfkOH5sVfFSn/KPGHmubNlRtLI="; + }) + # Fix external_client tests + # Remove when version > 2.15.0 + (fetchpatch { + name = "0002-mir-Fix-cannot_start_X_Server_and_outdated_tests.patch"; + url = "https://github.com/canonical/mir/commit/0704026bd06372ea8286a46d8c939286dd8a8c68.patch"; + hash = "sha256-k+51piPQandbHdm+ioqpBrb+C7Aqi2kugchAehZ1aiU="; + }) ]; }; -}) +} diff --git a/pkgs/servers/mir/update.sh b/pkgs/servers/mir/update.sh new file mode 100755 index 000000000000..bd969e9fceef --- /dev/null +++ b/pkgs/servers/mir/update.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused jq common-updater-scripts + +set -eou pipefail + +version="$(curl --silent "https://api.github.com/repos/canonical/mir/releases" | jq '.[0].tag_name' --raw-output)" + +update-source-version mir "${version:1}" --file=./pkgs/servers/mir/default.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 299f15f74d68..c69fe5d73aa6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26175,7 +26175,9 @@ with pkgs; buildGoModule = buildGo122Module; }; - mir = callPackage ../servers/mir { }; + inherit (callPackage ../servers/mir { }) + mir + mir_2_15; miriway = callPackage ../applications/window-managers/miriway { };