Commit e2627fbe authored by OPNA2608's avatar OPNA2608
Browse files

mir: Modernise derivation

- test-related inputs -> checkInputs
- use finalAttrs
- set meta.changelog
- set meta.pkgConfigModules, validate with validatePkgConfig
parent 10092e14
Loading
Loading
Loading
Loading
+35 −20
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
, lib
, fetchFromGitHub
, gitUpdater
, testers
, cmake
, pkg-config
, python3
@@ -34,26 +35,17 @@
, gtest
, umockdev
, wlcs
, validatePkgConfig
}:

let
  doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
  pythonEnv = python3.withPackages(ps: with ps; [
    pillow
  ] ++ lib.optionals doCheck [
    pygobject3
    python-dbusmock
  ]);
in

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "mir";
  version = "2.13.0";

  src = fetchFromGitHub {
    owner = "MirServer";
    repo = "mir";
    rev = "v${version}";
    rev = "v${finalAttrs.version}";
    hash = "sha256-Ip8p4mjcgmZQJTU4MNvWkTTtSJc+cCL3x1mMDFlZrVY=";
  };

@@ -98,7 +90,13 @@ stdenv.mkDerivation rec {
    libxslt
    lttng-ust # lttng-gen-tp
    pkg-config
    pythonEnv
    (python3.withPackages (ps: with ps; [
      pillow
    ] ++ lib.optionals finalAttrs.doCheck [
      pygobject3
      python-dbusmock
    ]))
    validatePkgConfig
  ];

  buildInputs = [
@@ -127,21 +125,23 @@ stdenv.mkDerivation rec {
    xorg.libXcursor
    xorg.xorgproto
    xwayland
  ] ++ lib.optionals doCheck [
    gtest
    umockdev
    wlcs
  ];

  nativeCheckInputs = [
    dbus
  ];

  checkInputs = [
    gtest
    umockdev
    wlcs
  ];

  buildFlags = [ "all" "doc" ];

  cmakeFlags = [
    "-DMIR_PLATFORM='gbm-kms;x11;eglstream-kms;wayland'"
    "-DMIR_ENABLE_TESTS=${if doCheck then "ON" else "OFF"}"
    "-DMIR_ENABLE_TESTS=${if finalAttrs.doCheck then "ON" else "OFF"}"
    # BadBufferTest.test_truncated_shm_file *doesn't* throw an error as the test expected, mark as such
    # https://github.com/MirServer/mir/pull/1947#issuecomment-811810872
    "-DMIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN=ON"
@@ -152,7 +152,7 @@ stdenv.mkDerivation rec {
    "-DMIR_BUILD_PLATFORM_TEST_HARNESS=OFF"
  ];

  inherit doCheck;
  doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

  preCheck = ''
    # Needs to be exactly /tmp so some failing tests don't get run, don't know why they fail yet
@@ -163,6 +163,7 @@ stdenv.mkDerivation rec {
  outputs = [ "out" "dev" "doc" ];

  passthru = {
    tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
    updateScript = gitUpdater {
      rev-prefix = "v";
    };
@@ -179,8 +180,22 @@ stdenv.mkDerivation rec {
  meta = with lib; {
    description = "A display server and Wayland compositor developed by Canonical";
    homepage = "https://mir-server.io";
    changelog = "https://github.com/MirServer/mir/releases/tag/v${finalAttrs.version}";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ onny OPNA2608 ];
    platforms = platforms.linux;
    pkgConfigModules = [
      "miral"
      "mircommon"
      "mircookie"
      "mircore"
      "miroil"
      "mirplatform"
      "mir-renderer-gl-dev"
      "mirrenderer"
      "mirserver"
      "mirtest"
      "mirwayland"
    ];
  };
}
})