wayland-scanner: split from wayland

We've used a wayland-scanner = wayland.bin alias for ages, to make
packages clearer and allow them to be independently overridden.
Going the whole way into splitting them into separate packages is
useful because it means we can have different meta.platforms
attributes for libwayland and wayland-scanner.

There is no duplication in outputs between the two packages — they
don't install any files in common.

Since we're no longer pulling just one output into nativeBuildInputs
of packages using wayland-scanner, we can use upstream's
wayland-scanner.pc, which gets installed into the dev output, rather
than providing our own.
This commit is contained in:
Alyssa Ross 2023-02-06 10:09:55 +00:00 committed by Florian Klink
parent 2aa25051f7
commit 921bd99f8d
7 changed files with 64 additions and 48 deletions

View File

@ -9,8 +9,6 @@
, darwin
}:
assert wayland.withLibraries;
let
stdenv = clangStdenv;
in

View File

@ -5,13 +5,10 @@
, pkg-config
, ninja
, wayland-scanner
, expat
, libxml2
, withLibraries ? stdenv.isLinux || stdenv.isDarwin
, withTests ? stdenv.isLinux
, libffi
, epoll-shim
, withDocumentation ? withLibraries && stdenv.hostPlatform == stdenv.buildPlatform
, withDocumentation ? stdenv.hostPlatform == stdenv.buildPlatform
, graphviz-nox
, doxygen
, libxslt
@ -23,15 +20,6 @@
, testers
}:
# Documentation is only built when building libraries.
assert withDocumentation -> withLibraries;
# Tests are only built when building libraries.
assert withTests -> withLibraries;
let
isCross = stdenv.buildPlatform != stdenv.hostPlatform;
in
stdenv.mkDerivation (finalAttrs: {
pname = "wayland";
version = "1.23.0";
@ -53,13 +41,13 @@ stdenv.mkDerivation (finalAttrs: {
sed -i '/os-wrappers-test/d' tests/meson.build
'';
outputs = [ "out" "bin" "dev" ] ++ lib.optionals withDocumentation [ "doc" "man" ];
outputs = [ "out" "dev" ] ++ lib.optionals withDocumentation [ "doc" "man" ];
separateDebugInfo = true;
mesonFlags = [
"-Ddocumentation=${lib.boolToString withDocumentation}"
"-Dlibraries=${lib.boolToString withLibraries}"
"-Dtests=${lib.boolToString withTests}"
(lib.mesonBool "documentation" withDocumentation)
(lib.mesonBool "tests" withTests)
(lib.mesonBool "scanner" false) # wayland-scanner is a separate derivation
];
depsBuildBuild = [
@ -70,7 +58,6 @@ stdenv.mkDerivation (finalAttrs: {
meson
pkg-config
ninja
] ++ lib.optionals isCross [
wayland-scanner
] ++ lib.optionals withDocumentation [
(graphviz-nox.override { pango = null; }) # To avoid an infinite recursion
@ -83,11 +70,8 @@ stdenv.mkDerivation (finalAttrs: {
];
buildInputs = [
expat
libxml2
] ++ lib.optionals withLibraries [
libffi
] ++ lib.optionals (withLibraries && !stdenv.hostPlatform.isLinux) [
] ++ lib.optionals (!stdenv.hostPlatform.isLinux) [
epoll-shim
] ++ lib.optionals withDocumentation [
docbook_xsl
@ -95,20 +79,7 @@ stdenv.mkDerivation (finalAttrs: {
docbook_xml_dtd_42
];
postFixup = ''
# The pkg-config file is required for cross-compilation:
mkdir -p $bin/lib/pkgconfig/
cat <<EOF > $bin/lib/pkgconfig/wayland-scanner.pc
wayland_scanner=$bin/bin/wayland-scanner
Name: Wayland Scanner
Description: Wayland scanner
Version: ${finalAttrs.version}
EOF
'';
passthru = {
inherit withLibraries;
tests.pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
@ -130,8 +101,6 @@ stdenv.mkDerivation (finalAttrs: {
platforms = platforms.unix;
maintainers = with maintainers; [ primeos codyopel qyliss ];
pkgConfigModules = [
"wayland-scanner"
] ++ lib.optionals withLibraries [
"wayland-client"
"wayland-cursor"
"wayland-egl"

View File

@ -8,8 +8,9 @@ stdenv.mkDerivation rec {
pname = "wayland-protocols";
version = "1.36";
doCheck = stdenv.hostPlatform == stdenv.buildPlatform &&
# https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/48
doCheck = stdenv.hostPlatform == stdenv.buildPlatform && stdenv.hostPlatform.linker == "bfd" && wayland.withLibraries;
stdenv.hostPlatform.linker == "bfd" && lib.meta.availableOn stdenv.hostPlatform wayland;
src = fetchurl {
url = "https://gitlab.freedesktop.org/wayland/${pname}/-/releases/${version}/downloads/${pname}-${version}.tar.xz";
@ -22,7 +23,8 @@ stdenv.mkDerivation rec {
depsBuildBuild = [ pkg-config ];
nativeBuildInputs = [ meson ninja wayland-scanner ];
nativeCheckInputs = [ python3 wayland ];
nativeCheckInputs = [ python3 ];
checkInputs = [ wayland ];
mesonFlags = [ "-Dtests=${lib.boolToString doCheck}" ];

View File

@ -0,0 +1,48 @@
{
lib,
stdenv,
wayland,
meson,
pkg-config,
ninja,
wayland-scanner,
expat,
libxml2,
}:
stdenv.mkDerivation {
pname = "wayland-scanner";
inherit (wayland) version src;
outputs = [
"out"
"bin"
"dev"
];
separateDebugInfo = true;
mesonFlags = [
(lib.mesonBool "documentation" false)
(lib.mesonBool "libraries" false)
(lib.mesonBool "tests" false)
];
depsBuildBuild = [ pkg-config ];
nativeBuildInputs = [
meson
pkg-config
ninja
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) wayland-scanner;
buildInputs = [
expat
libxml2
];
meta = with lib; {
inherit (wayland.meta) homepage license maintainers;
description = "C code generator for Wayland protocol XML files";
platforms = platforms.unix;
};
}

View File

@ -21,7 +21,7 @@ buildPythonPackage rec {
};
depsBuildBuild = [ pkg-config ];
nativeBuildInputs = [ pkg-config wayland-scanner ];
nativeBuildInputs = [ wayland-scanner ];
propagatedNativeBuildInputs = [ cffi ];
buildInputs = [ wayland ];
propagatedBuildInputs = [ cffi ];

View File

@ -28,8 +28,6 @@ stdenv.mkDerivation rec {
sha256 = "sha256-MEaj0mp7BRr3690lel8jv+sWDK1u2VIynN/x6fHtSWs=";
};
strictDeps = true;
depsBuildBuild = [
pkg-config
];
@ -57,9 +55,10 @@ stdenv.mkDerivation rec {
];
mesonFlags = [
"-Dwith-system-data-files=true"
"-Dgles1=disabled"
"-Dosmesa=disabled"
"-Degl=${if stdenv.isDarwin then "disabled" else "auto"}"
(lib.mesonEnable "libdrm" (stdenv.isLinux))
(lib.mesonEnable "osmesa" (mesa ? osmesa))
(lib.mesonEnable "wayland" (lib.meta.availableOn stdenv.hostPlatform wayland))
];
meta = with lib; {

View File

@ -24271,7 +24271,7 @@ with pkgs;
wavpack = callPackage ../development/libraries/wavpack { };
wayland = darwin.apple_sdk_11_0.callPackage ../development/libraries/wayland { };
wayland-scanner = wayland.bin;
wayland-scanner = callPackage ../development/libraries/wayland/scanner.nix { };
wayland-protocols = callPackage ../development/libraries/wayland/protocols.nix { };