From 7790eafbdcbc85a8e48912189400565dd039cb64 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 23 Apr 2022 23:37:49 +0200 Subject: pkg-configPackages: init --- pkgs/test/default.nix | 2 + pkgs/test/pkg-config-packages.nix | 34 ++++++ pkgs/top-level/all-packages.nix | 2 + pkgs/top-level/pkg-config-packages.nix | 199 +++++++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 pkgs/test/pkg-config-packages.nix create mode 100644 pkgs/top-level/pkg-config-packages.nix diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 818001018b3a..8ff0e163395f 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -51,6 +51,8 @@ with pkgs; php = recurseIntoAttrs (callPackages ./php {}); + pkg-configPackages = callPackage ./pkg-config-packages.nix { }; + rustCustomSysroot = callPackage ./rust-sysroot {}; buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { }; importCargoLock = callPackage ../build-support/rust/test/import-cargo-lock { }; diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix new file mode 100644 index 000000000000..d61902cf1f46 --- /dev/null +++ b/pkgs/test/pkg-config-packages.nix @@ -0,0 +1,34 @@ +{ lib, pkg-config, pkg-configPackages, runCommand }: +let + allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTest k v) pkg-configPackages; + + # nix-build rejects attribute names with periods + # This will build those regardless. + tests-combined = runCommand "pkg-config-checks" { + allTests = lib.attrValues allTests; + } '' + touch $out + ''; + + makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" { + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ pkg ]; + inherit moduleName; + } '' + echo "checking pkg-config module $moduleName in $buildInputs" + set +e + version="$(pkg-config --modversion $moduleName)" + r=$? + set -e + if [[ $r = 0 ]]; then + echo "✅ pkg-config module $moduleName exists and has version $version" + echo "$version" > $out + else + echo "These modules were available in the input propagation closure:" + pkg-config --list-all + echo "❌ pkg-config module $moduleName was not found" + false + fi + ''; +in + allTests // { inherit tests-combined; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1463780e90b6..6b61bcccee60 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -112,6 +112,8 @@ with pkgs; tests = callPackages ../test {}; + pkg-configPackages = import ./pkg-config-packages.nix pkgs; + ### Nixpkgs maintainer tools nix-generate-from-cpan = callPackage ../../maintainers/scripts/nix-generate-from-cpan.nix { }; diff --git a/pkgs/top-level/pkg-config-packages.nix b/pkgs/top-level/pkg-config-packages.nix new file mode 100644 index 000000000000..41613e20caf4 --- /dev/null +++ b/pkgs/top-level/pkg-config-packages.nix @@ -0,0 +1,199 @@ +/* A set of aliases to be used in generated expressions. + + In case of ambiguity, this will pick a sensible default. + + This was initially based on cabal2nix's mapping. + + It'd be nice to generate this mapping, based on a set of derivations. + It can not be fully automated, so it should be a expression or tool + that makes suggestions about which pkg-config module names can be added. + */ +pkgs: { + inherit (pkgs) + bzip2 + freealut + libb2 + libsass + taglib + zlib + ; + alsa = pkgs.alsa-lib; + alsa-topology = pkgs.alsa-lib; + "appindicator-0.1" = pkgs.libappindicator-gtk2; + "appindicator3-0.1" = pkgs.libappindicator-gtk3; + cairo-gobject = pkgs.cairo; + cairo-pdf = pkgs.cairo; + cairo-ps = pkgs.cairo; + cairo-svg = pkgs.cairo; + + "ncurses++" = pkgs.ncurses; + "ncurses++w" = pkgs.ncurses; + form = pkgs.ncurses; + formw = pkgs.ncurses; + menu = pkgs.ncurses; + menuw = pkgs.ncurses; + ncurses = pkgs.ncurses; + ncursesw = pkgs.ncurses; + panel = pkgs.ncurses; + panelw = pkgs.ncurses; + + "dbusmenu-glib-0.4" = pkgs.libdbusmenu; + "dbusmenu-gtk3-0.4" = pkgs.libdbusmenu-gtk3; # TODO: also needs gtk3. Use build propagation? + fftw3 = pkgs.fftw; + fftw3f = pkgs.fftwFloat; + freetype2 = pkgs.freetype; + "gdk-2.0" = pkgs.gtk2; + "gdk-3.0" = pkgs.gtk3; + "gdk-pixbuf-2.0" = pkgs.gdk-pixbuf; + "gdk-x11-2.0" = pkgs.gtk2-x11; + "gdk-x11-3.0" = pkgs.gtk3-x11; + geos = pkgs.geos; + "gio-2.0" = pkgs.glib; + gl = pkgs.libGL; + glew = pkgs.glew; + glu = pkgs.libGLU; + glut = pkgs.freeglut; + gnome-keyring-1 = pkgs.libgnome-keyring; + "gnome-vfs-2.0" = pkgs.gnome2.gnome_vfs; + "gnome-vfs-module-2.0" = pkgs.gnome2.gnome_vfs; + "gobject-2.0" = pkgs.glib; + "gobject-introspection-1.0" = pkgs.gobject-introspection; + "gstreamer-audio-1.0" = pkgs.gst_all_1.gst-plugins-base; + "gstreamer-base-1.0" = pkgs.gst_all_1.gst-plugins-base; + "gstreamer-controller-1.0" = pkgs.gst_all_1.gstreamer; + "gstreamer-net-1.0" = pkgs.gst_all_1.gst-plugins-base; + "gstreamer-video-1.0" = pkgs.gst_all_1.gst-plugins-base; + "gthread-2.0" = pkgs.glib; + "gtk+-2.0" = pkgs.gtk2; + "gtk+-3.0" = pkgs.gtk3; + "gtk+-x11-2.0" = pkgs.gtk2-x11; + "gtksourceview-3.0" = pkgs.gtksourceview3; + hidapi-libusb = pkgs.hidapi; + icu-i18n = pkgs.icu; + icu-uc = pkgs.icu; + icu-io = pkgs.icu; + libidn = pkgs.libidn; + IL = pkgs.libdevil; + ImageMagick = pkgs.imagemagick; + imlib2 = pkgs.imlib2; + jack = pkgs.libjack2; + "javascriptcoregtk-4.0" = pkgs.webkitgtk; + libjpeg = pkgs.libjpeg; + libturbojpeg = pkgs.libjpeg; + lapack = pkgs.liblapack; + libavutil = pkgs.ffmpeg; + libbrotlienc = pkgs.brotli; + libbrotlidec = pkgs.brotli; + libgsasl = pkgs.gsasl; + libpcre = pkgs.pcre; + libpcre2-8 = pkgs.pcre2; + libpcre2-16 = pkgs.pcre2; + libpcre2-32 = pkgs.pcre2; + libpcre2-posix = pkgs.pcre2; + libqrencode = pkgs.qrencode; + libR = pkgs.R; + libsecp256k1 = pkgs.secp256k1; + "libsoup-gnome-2.4" = pkgs.libsoup; + libsystemd = pkgs.systemd; + libudev = pkgs.systemd; + "libxml-2.0" = pkgs.libxml2; + libzip = pkgs.libzip; + libzmq = pkgs.zeromq; + liblzma = pkgs.xz; + m = null; # in stdenv + libmagic = pkgs.file; + MagickWand = pkgs.imagemagick; + libmnl = pkgs.libmnl; + + ompi = pkgs.openmpi; + ompi-c = pkgs.openmpi; + ompi-cxx = pkgs.openmpi; + ompi-fort = pkgs.openmpi; + ompi-f77 = pkgs.openmpi; + ompi-f90 = pkgs.openmpi; + orte = pkgs.openmpi; + + netsnmp = pkgs.net_snmp; + nix-cmd = pkgs.nix; + nix-expr = pkgs.nix; + nix-main = pkgs.nix; + nix-store = pkgs.nix; + libnotify = pkgs.libnotify; + odbc = pkgs.unixODBC; + openblas = pkgs.openblasCompat; + pangocairo = pkgs.pango; + libpcap = pkgs.libpcap; + libpng = pkgs.libpng; + poppler-glib = pkgs.poppler_gi; + libpq = pkgs.postgresql; + libpgtypes = pkgs.postgresql; + libecpg = pkgs.postgresql; + libecpg_compat = pkgs.postgresql; + pthread = null; # in stdenv + libpulse = pkgs.libpulseaudio; + libpulse-simple = pkgs.libpulseaudio; + libpulse-mainloop-glib = pkgs.libpulseaudio; + python = pkgs.python3; + + Qt5Concurrent = pkgs.qt5.qtbase; + Qt5Core = pkgs.qt5.qtbase; + Qt5DBus = pkgs.qt5.qtbase; + Qt5Gui = pkgs.qt5.qtbase; + Qt5Network = pkgs.qt5.qtbase; + Qt5OpenGL = pkgs.qt5.qtbase; + Qt5OpenGLExtensions = pkgs.qt5.qtbase; + Qt5PrintSupport = pkgs.qt5.qtbase; + Qt5Sql = pkgs.qt5.qtbase; + Qt5Test = pkgs.qt5.qtbase; + Qt5Widgets = pkgs.qt5.qtbase; + Qt5Xml = pkgs.qt5.qtbase; + + Qt5Qml = pkgs.qt5.qtdeclarative; + Qt5QmlModels = pkgs.qt5.qtdeclarative; + Qt5Quick = pkgs.qt5.qtdeclarative; + Qt5QuickTest = pkgs.qt5.qtdeclarative; + Qt5QuickWidgets = pkgs.qt5.qtdeclarative; + + librtlsdr = pkgs.rtl-sdr; + "ruby-2.7" = pkgs.ruby_2_7; + "ruby-3.0" = pkgs.ruby_3_0; + "ruby-3.1" = pkgs.ruby_3_1; + libsctp = pkgs.lksctp-tools; # This is linux-specific, we should create a common attribute if we add sctp support for other systems. + sdl2 = pkgs.SDL2; + sndfile = pkgs.libsndfile; + SoapySDR = pkgs.soapysdr; + libsodium = pkgs.libsodium; + sqlite3 = pkgs.sqlite; + libssh2 = pkgs.libssh2; + openssl = pkgs.openssl; + libssl = pkgs.openssl; + libcrypto = pkgs.openssl; + libstatgrab = pkgs.libstatgrab; + taglib_c = pkgs.taglib; + tdjson = pkgs.tdlib; + tensorflow = pkgs.libtensorflow; + uuid = pkgs.libossp_uuid; + "vte-2.91" = pkgs.vte; + wayland-client = pkgs.wayland; + wayland-cursor = pkgs.wayland; + egl = pkgs.libGL; + wayland-server = pkgs.wayland; + "webkit2gtk-4.0" = pkgs.webkitgtk; + "webkit2gtk-web-extension-4.0" = pkgs.webkitgtk; + x11 = pkgs.xorg.libX11; + xau = pkgs.xorg.libXau; + xcursor = pkgs.xorg.libXcursor; + xerces-c = pkgs.xercesc; + xext = pkgs.xorg.libXext; + xft = pkgs.xorg.libXft; + xi = pkgs.xorg.libXi; + xinerama = pkgs.xorg.libXinerama; + xkbcommon = pkgs.libxkbcommon; + xpm = pkgs.xorg.libXpm; + xrandr = pkgs.xorg.libXrandr; + xrender = pkgs.xorg.libXrender; + xscrnsaver = pkgs.xorg.libXScrnSaver; + xtst = pkgs.xorg.libXtst; + xxf86vm = pkgs.xorg.libXxf86vm; + "yaml-0.1" = pkgs.libyaml; +} -- cgit v1.2.3 From e93cfb250b683f3ffd9adc957c14b5b3b2e108ae Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 23 Jan 2023 19:08:46 +0100 Subject: tests.pkg-configPackages: Filter out unsupported packages --- pkgs/test/default.nix | 17 ++++++++++++++++- pkgs/test/pkg-config-packages.nix | 24 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 8ff0e163395f..82134b051d4e 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -51,7 +51,22 @@ with pkgs; php = recurseIntoAttrs (callPackages ./php {}); - pkg-configPackages = callPackage ./pkg-config-packages.nix { }; + pkg-configPackages = + let + # pkg-configPackages test needs a Nixpkgs with allowUnsupportedPlatform + # in order to filter out the unsupported packages without throwing any errors + # tryEval would be too fragile, masking different problems as if they're + # unsupported platform problems. + allPkgs = import ../top-level { + system = pkgs.stdenv.hostPlatform.system; + localSystem = pkgs.stdenv.hostPlatform.system; + config = { + allowUnsupportedSystem = true; + }; + overlays = []; + }; + in + allPkgs.callPackage ./pkg-config-packages.nix { }; rustCustomSysroot = callPackage ./rust-sysroot {}; buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { }; diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix index d61902cf1f46..8e4e5253f9b1 100644 --- a/pkgs/test/pkg-config-packages.nix +++ b/pkgs/test/pkg-config-packages.nix @@ -1,6 +1,8 @@ { lib, pkg-config, pkg-configPackages, runCommand }: let - allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTest k v) pkg-configPackages; + inherit (lib.strings) escapeNixIdentifier; + + allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) pkg-configPackages; # nix-build rejects attribute names with periods # This will build those regardless. @@ -10,6 +12,26 @@ let touch $out ''; + makePkgConfigTestMaybe = moduleName: pkg: + if ! lib.isDerivation pkg + then + throw "pkg-config module `${escapeNixIdentifier moduleName}` is not defined to be a derivation. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs." + + else if ! pkg?meta.unsupported + then + throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.unsupported` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs." + + else if pkg.meta.unsupported + then + # We return `null` instead of doing a `filterAttrs`, because with + # `filterAttrs` the evaluator would not be able to return the attribute + # set without first evaluating all of the attribute _values_. This would + # be rather expensive, and severly slow down the use case of getting a + # single test, which we want to do in `passthru.tests`, or interactively. + null + + else makePkgConfigTest moduleName pkg; + makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" { nativeBuildInputs = [ pkg-config ]; buildInputs = [ pkg ]; -- cgit v1.2.3 From 04b06e83dc3438512896abdb38b7d6a8dd8adb26 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 23 Jan 2023 19:11:20 +0100 Subject: tests.pkg-configPackages: Filter out broken packages Some packages are only marked broken on specific platforms, so we filter those out as well. Consequently, this might not raise an error if the attribute value needs to point to a different pkgs attribute, but this is not something we can detect. For now, we'll have to rely on users of such pkg-config packages to report that kind of error. There's really not much we can do about this here. --- pkgs/test/pkg-config-packages.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix index 8e4e5253f9b1..2d14d9402f0e 100644 --- a/pkgs/test/pkg-config-packages.nix +++ b/pkgs/test/pkg-config-packages.nix @@ -30,6 +30,13 @@ let # single test, which we want to do in `passthru.tests`, or interactively. null + else if ! pkg?meta.broken + then + throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.broken` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config.packages.nix` in Nixpkgs." + + else if pkg.meta.broken + then null + else makePkgConfigTest moduleName pkg; makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" { -- cgit v1.2.3 From b576b17fb00af05968a0ccaddf7ee63857d8d5e2 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 23 Jan 2023 19:42:24 +0100 Subject: zlib: Add tests.pkg-configPackages --- pkgs/development/libraries/zlib/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 52654b6541e3..0aa37c86b795 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -8,6 +8,7 @@ # the `.pc` file lists only the main output's lib dir. # If false, and if `{ static = true; }`, the .a stays in the main output. , splitStaticOutput ? shared && static +, tests }: # Without either the build will actually still succeed because the build @@ -125,6 +126,14 @@ stdenv.mkDerivation rec { "SHARED_MODE=1" ]; + passthru = { + tests = { + # NB: this may test a different variant of zlib than the package that + # carries this `tests` attribute, due to overriding. + pkg-configPackages = tests.pkg-configPackages.zlib; + }; + }; + meta = with lib; { homepage = "https://zlib.net"; description = "Lossless data-compression library"; -- cgit v1.2.3 From 2d4e78fb8bd3420d31879f5669160b1a62d47fb0 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 25 Jan 2023 11:54:02 +0100 Subject: tests.pkg-configPackages: Copy meta attributes for licensing concerns --- pkgs/test/pkg-config-packages.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix index 2d14d9402f0e..be046c8cacca 100644 --- a/pkgs/test/pkg-config-packages.nix +++ b/pkgs/test/pkg-config-packages.nix @@ -43,6 +43,24 @@ let nativeBuildInputs = [ pkg-config ]; buildInputs = [ pkg ]; inherit moduleName; + meta = { + description = "Test whether ${pkg.name} exposes pkg-config module ${moduleName}"; + } + # Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org, + # as hydra can't check this meta info in dependencies. + # The test itself is just Nixpkgs, with MIT license. + // builtins.intersectAttrs + { + available = throw "unused"; + broken = throw "unused"; + insecure = throw "unused"; + license = throw "unused"; + maintainers = throw "unused"; + platforms = throw "unused"; + unfree = throw "unused"; + unsupported = throw "unused"; + } + pkg.meta; } '' echo "checking pkg-config module $moduleName in $buildInputs" set +e -- cgit v1.2.3 From 75a70ff129f6442ee8554470d71ce48fab00a527 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 25 Jan 2023 12:08:50 +0100 Subject: pkg-configPackages: Fixes for darwin --- pkgs/top-level/pkg-config-packages.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/top-level/pkg-config-packages.nix b/pkgs/top-level/pkg-config-packages.nix index 41613e20caf4..e30b6cc45509 100644 --- a/pkgs/top-level/pkg-config-packages.nix +++ b/pkgs/top-level/pkg-config-packages.nix @@ -68,7 +68,9 @@ pkgs: { "gtk+-3.0" = pkgs.gtk3; "gtk+-x11-2.0" = pkgs.gtk2-x11; "gtksourceview-3.0" = pkgs.gtksourceview3; - hidapi-libusb = pkgs.hidapi; + hidapi = if pkgs.stdenv.isDarwin then pkgs.hidapi else null; + hidapi-hidraw = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; + hidapi-libusb = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; icu-i18n = pkgs.icu; icu-uc = pkgs.icu; icu-io = pkgs.icu; @@ -132,7 +134,7 @@ pkgs: { pthread = null; # in stdenv libpulse = pkgs.libpulseaudio; libpulse-simple = pkgs.libpulseaudio; - libpulse-mainloop-glib = pkgs.libpulseaudio; + libpulse-mainloop-glib = if pkgs.stdenv.isDarwin then null else pkgs.libpulseaudio; python = pkgs.python3; Qt5Concurrent = pkgs.qt5.qtbase; @@ -174,10 +176,11 @@ pkgs: { tensorflow = pkgs.libtensorflow; uuid = pkgs.libossp_uuid; "vte-2.91" = pkgs.vte; - wayland-client = pkgs.wayland; - wayland-cursor = pkgs.wayland; - egl = pkgs.libGL; - wayland-server = pkgs.wayland; + wayland-client = if pkgs.stdenv.isDarwin then null else pkgs.wayland; + wayland-cursor = if pkgs.stdenv.isDarwin then null else pkgs.wayland; + egl = if pkgs.stdenv.isDarwin then null else pkgs.libGL; + wayland-scanner = pkgs.wayland; + wayland-server = if pkgs.stdenv.isDarwin then null else pkgs.wayland; "webkit2gtk-4.0" = pkgs.webkitgtk; "webkit2gtk-web-extension-4.0" = pkgs.webkitgtk; x11 = pkgs.xorg.libX11; -- cgit v1.2.3 From 159ad20b894a9af2893cacfcca19fcec7f21fa06 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 25 Jan 2023 12:59:38 +0100 Subject: doc: Add pkg-config section --- doc/languages-frameworks/index.xml | 1 + doc/languages-frameworks/pkg-config.section.md | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 doc/languages-frameworks/pkg-config.section.md diff --git a/doc/languages-frameworks/index.xml b/doc/languages-frameworks/index.xml index 7d404643d369..3774924c0be4 100644 --- a/doc/languages-frameworks/index.xml +++ b/doc/languages-frameworks/index.xml @@ -32,6 +32,7 @@ + diff --git a/doc/languages-frameworks/pkg-config.section.md b/doc/languages-frameworks/pkg-config.section.md new file mode 100644 index 000000000000..f19f56840345 --- /dev/null +++ b/doc/languages-frameworks/pkg-config.section.md @@ -0,0 +1,9 @@ +# pkg-config {#sec-pkg-config} + +*pkg-config* is a unified interface for declaring and querying built C/C++ libraries. + +Nixpkgs provides a couple of facilities for working with this tool. + + - A [setup hook](#setup-hook-pkg-config) bundled with in the `pkg-config` package, to bring a derivation's declared build inputs into the environment. + - The [`validatePkgConfig` setup hook](https://nixos.org/manual/nixpkgs/stable/#validatepkgconfig), for packages that provide pkg-config modules. + - The `pkg-configPackages` package set: a set of aliases, named after the modules they provide. This is meant to be used by language-to-nix integrations. Hand-written packages should use the normal Nixpkgs attribute name instead. -- cgit v1.2.3 From 90fdbf5f394f3bb7d49992702157df7d93056055 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 25 Jan 2023 17:07:12 +0100 Subject: Revert "zlib: Add tests.pkg-configPackages" `passthru.tests` is an interesting addition, but it is too manual of a solution, and is unlikely to be as useful as it needs to be to cover its cost of adding this to a ton of packages. This reverts commit c25dd2f01e93d79237c56b61f51c034616be0a11. --- pkgs/development/libraries/zlib/default.nix | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 0aa37c86b795..52654b6541e3 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -8,7 +8,6 @@ # the `.pc` file lists only the main output's lib dir. # If false, and if `{ static = true; }`, the .a stays in the main output. , splitStaticOutput ? shared && static -, tests }: # Without either the build will actually still succeed because the build @@ -126,14 +125,6 @@ stdenv.mkDerivation rec { "SHARED_MODE=1" ]; - passthru = { - tests = { - # NB: this may test a different variant of zlib than the package that - # carries this `tests` attribute, due to overriding. - pkg-configPackages = tests.pkg-configPackages.zlib; - }; - }; - meta = with lib; { homepage = "https://zlib.net"; description = "Lossless data-compression library"; -- cgit v1.2.3 From a010129bf87c2afcb2f60db410cc535fef299f8c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 25 Jan 2023 17:09:33 +0100 Subject: pkg-configPackages -> defaultPkgConfigPackages This better reflects the purpose of the package set, while leaving room for a fancier, more complete implementation of the concept, with a nicer name. --- doc/languages-frameworks/pkg-config.section.md | 2 +- pkgs/test/default.nix | 4 ++-- pkgs/test/pkg-config-packages.nix | 4 ++-- pkgs/top-level/all-packages.nix | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/languages-frameworks/pkg-config.section.md b/doc/languages-frameworks/pkg-config.section.md index f19f56840345..ee0a471be3e5 100644 --- a/doc/languages-frameworks/pkg-config.section.md +++ b/doc/languages-frameworks/pkg-config.section.md @@ -6,4 +6,4 @@ Nixpkgs provides a couple of facilities for working with this tool. - A [setup hook](#setup-hook-pkg-config) bundled with in the `pkg-config` package, to bring a derivation's declared build inputs into the environment. - The [`validatePkgConfig` setup hook](https://nixos.org/manual/nixpkgs/stable/#validatepkgconfig), for packages that provide pkg-config modules. - - The `pkg-configPackages` package set: a set of aliases, named after the modules they provide. This is meant to be used by language-to-nix integrations. Hand-written packages should use the normal Nixpkgs attribute name instead. + - The `defaultPkgConfigPackages` package set: a set of aliases, named after the modules they provide. This is meant to be used by language-to-nix integrations. Hand-written packages should use the normal Nixpkgs attribute name instead. diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 82134b051d4e..72b22f7f6865 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -51,9 +51,9 @@ with pkgs; php = recurseIntoAttrs (callPackages ./php {}); - pkg-configPackages = + defaultPkgConfigPackages = let - # pkg-configPackages test needs a Nixpkgs with allowUnsupportedPlatform + # defaultPkgConfigPackages test needs a Nixpkgs with allowUnsupportedPlatform # in order to filter out the unsupported packages without throwing any errors # tryEval would be too fragile, masking different problems as if they're # unsupported platform problems. diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix index be046c8cacca..8cb6cc57753f 100644 --- a/pkgs/test/pkg-config-packages.nix +++ b/pkgs/test/pkg-config-packages.nix @@ -1,8 +1,8 @@ -{ lib, pkg-config, pkg-configPackages, runCommand }: +{ lib, pkg-config, defaultPkgConfigPackages, runCommand }: let inherit (lib.strings) escapeNixIdentifier; - allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) pkg-configPackages; + allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) defaultPkgConfigPackages; # nix-build rejects attribute names with periods # This will build those regardless. diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6b61bcccee60..cde388312abf 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -112,7 +112,7 @@ with pkgs; tests = callPackages ../test {}; - pkg-configPackages = import ./pkg-config-packages.nix pkgs; + defaultPkgConfigPackages = import ./pkg-config-packages.nix pkgs; ### Nixpkgs maintainer tools -- cgit v1.2.3 From 81a541e6b657cb6dd1943079da48a550b89b87ba Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Jan 2023 08:18:21 +0100 Subject: defaultPkgConfigPackages: Make it JSON With a bit of help from: ``` nix-repl> :b (formats.json {}).generate "hi" { modules = lib.mapAttrs (k: v: { attrPath = v; }) (p (paths [] pkgs // { stdenv = { isDarwin = false; isLinux = false; };})); } ``` --- pkgs/top-level/pkg-config-packages.nix | 224 +----- pkgs/top-level/pkg-config/pkg-config-data.json | 940 +++++++++++++++++++++++++ 2 files changed, 974 insertions(+), 190 deletions(-) create mode 100644 pkgs/top-level/pkg-config/pkg-config-data.json diff --git a/pkgs/top-level/pkg-config-packages.nix b/pkgs/top-level/pkg-config-packages.nix index e30b6cc45509..8d428cfb2182 100644 --- a/pkgs/top-level/pkg-config-packages.nix +++ b/pkgs/top-level/pkg-config-packages.nix @@ -8,195 +8,39 @@ It can not be fully automated, so it should be a expression or tool that makes suggestions about which pkg-config module names can be added. */ -pkgs: { - inherit (pkgs) - bzip2 - freealut - libb2 - libsass - taglib - zlib +pkgs: + +let + inherit (pkgs) lib; + inherit (lib) + flip + mapAttrs + getAttrFromPath + importJSON ; - alsa = pkgs.alsa-lib; - alsa-topology = pkgs.alsa-lib; - "appindicator-0.1" = pkgs.libappindicator-gtk2; - "appindicator3-0.1" = pkgs.libappindicator-gtk3; - cairo-gobject = pkgs.cairo; - cairo-pdf = pkgs.cairo; - cairo-ps = pkgs.cairo; - cairo-svg = pkgs.cairo; - "ncurses++" = pkgs.ncurses; - "ncurses++w" = pkgs.ncurses; - form = pkgs.ncurses; - formw = pkgs.ncurses; - menu = pkgs.ncurses; - menuw = pkgs.ncurses; - ncurses = pkgs.ncurses; - ncursesw = pkgs.ncurses; - panel = pkgs.ncurses; - panelw = pkgs.ncurses; - - "dbusmenu-glib-0.4" = pkgs.libdbusmenu; - "dbusmenu-gtk3-0.4" = pkgs.libdbusmenu-gtk3; # TODO: also needs gtk3. Use build propagation? - fftw3 = pkgs.fftw; - fftw3f = pkgs.fftwFloat; - freetype2 = pkgs.freetype; - "gdk-2.0" = pkgs.gtk2; - "gdk-3.0" = pkgs.gtk3; - "gdk-pixbuf-2.0" = pkgs.gdk-pixbuf; - "gdk-x11-2.0" = pkgs.gtk2-x11; - "gdk-x11-3.0" = pkgs.gtk3-x11; - geos = pkgs.geos; - "gio-2.0" = pkgs.glib; - gl = pkgs.libGL; - glew = pkgs.glew; - glu = pkgs.libGLU; - glut = pkgs.freeglut; - gnome-keyring-1 = pkgs.libgnome-keyring; - "gnome-vfs-2.0" = pkgs.gnome2.gnome_vfs; - "gnome-vfs-module-2.0" = pkgs.gnome2.gnome_vfs; - "gobject-2.0" = pkgs.glib; - "gobject-introspection-1.0" = pkgs.gobject-introspection; - "gstreamer-audio-1.0" = pkgs.gst_all_1.gst-plugins-base; - "gstreamer-base-1.0" = pkgs.gst_all_1.gst-plugins-base; - "gstreamer-controller-1.0" = pkgs.gst_all_1.gstreamer; - "gstreamer-net-1.0" = pkgs.gst_all_1.gst-plugins-base; - "gstreamer-video-1.0" = pkgs.gst_all_1.gst-plugins-base; - "gthread-2.0" = pkgs.glib; - "gtk+-2.0" = pkgs.gtk2; - "gtk+-3.0" = pkgs.gtk3; - "gtk+-x11-2.0" = pkgs.gtk2-x11; - "gtksourceview-3.0" = pkgs.gtksourceview3; - hidapi = if pkgs.stdenv.isDarwin then pkgs.hidapi else null; - hidapi-hidraw = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; - hidapi-libusb = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; - icu-i18n = pkgs.icu; - icu-uc = pkgs.icu; - icu-io = pkgs.icu; - libidn = pkgs.libidn; - IL = pkgs.libdevil; - ImageMagick = pkgs.imagemagick; - imlib2 = pkgs.imlib2; - jack = pkgs.libjack2; - "javascriptcoregtk-4.0" = pkgs.webkitgtk; - libjpeg = pkgs.libjpeg; - libturbojpeg = pkgs.libjpeg; - lapack = pkgs.liblapack; - libavutil = pkgs.ffmpeg; - libbrotlienc = pkgs.brotli; - libbrotlidec = pkgs.brotli; - libgsasl = pkgs.gsasl; - libpcre = pkgs.pcre; - libpcre2-8 = pkgs.pcre2; - libpcre2-16 = pkgs.pcre2; - libpcre2-32 = pkgs.pcre2; - libpcre2-posix = pkgs.pcre2; - libqrencode = pkgs.qrencode; - libR = pkgs.R; - libsecp256k1 = pkgs.secp256k1; - "libsoup-gnome-2.4" = pkgs.libsoup; - libsystemd = pkgs.systemd; - libudev = pkgs.systemd; - "libxml-2.0" = pkgs.libxml2; - libzip = pkgs.libzip; - libzmq = pkgs.zeromq; - liblzma = pkgs.xz; - m = null; # in stdenv - libmagic = pkgs.file; - MagickWand = pkgs.imagemagick; - libmnl = pkgs.libmnl; - - ompi = pkgs.openmpi; - ompi-c = pkgs.openmpi; - ompi-cxx = pkgs.openmpi; - ompi-fort = pkgs.openmpi; - ompi-f77 = pkgs.openmpi; - ompi-f90 = pkgs.openmpi; - orte = pkgs.openmpi; - - netsnmp = pkgs.net_snmp; - nix-cmd = pkgs.nix; - nix-expr = pkgs.nix; - nix-main = pkgs.nix; - nix-store = pkgs.nix; - libnotify = pkgs.libnotify; - odbc = pkgs.unixODBC; - openblas = pkgs.openblasCompat; - pangocairo = pkgs.pango; - libpcap = pkgs.libpcap; - libpng = pkgs.libpng; - poppler-glib = pkgs.poppler_gi; - libpq = pkgs.postgresql; - libpgtypes = pkgs.postgresql; - libecpg = pkgs.postgresql; - libecpg_compat = pkgs.postgresql; - pthread = null; # in stdenv - libpulse = pkgs.libpulseaudio; - libpulse-simple = pkgs.libpulseaudio; - libpulse-mainloop-glib = if pkgs.stdenv.isDarwin then null else pkgs.libpulseaudio; - python = pkgs.python3; - - Qt5Concurrent = pkgs.qt5.qtbase; - Qt5Core = pkgs.qt5.qtbase; - Qt5DBus = pkgs.qt5.qtbase; - Qt5Gui = pkgs.qt5.qtbase; - Qt5Network = pkgs.qt5.qtbase; - Qt5OpenGL = pkgs.qt5.qtbase; - Qt5OpenGLExtensions = pkgs.qt5.qtbase; - Qt5PrintSupport = pkgs.qt5.qtbase; - Qt5Sql = pkgs.qt5.qtbase; - Qt5Test = pkgs.qt5.qtbase; - Qt5Widgets = pkgs.qt5.qtbase; - Qt5Xml = pkgs.qt5.qtbase; - - Qt5Qml = pkgs.qt5.qtdeclarative; - Qt5QmlModels = pkgs.qt5.qtdeclarative; - Qt5Quick = pkgs.qt5.qtdeclarative; - Qt5QuickTest = pkgs.qt5.qtdeclarative; - Qt5QuickWidgets = pkgs.qt5.qtdeclarative; - - librtlsdr = pkgs.rtl-sdr; - "ruby-2.7" = pkgs.ruby_2_7; - "ruby-3.0" = pkgs.ruby_3_0; - "ruby-3.1" = pkgs.ruby_3_1; - libsctp = pkgs.lksctp-tools; # This is linux-specific, we should create a common attribute if we add sctp support for other systems. - sdl2 = pkgs.SDL2; - sndfile = pkgs.libsndfile; - SoapySDR = pkgs.soapysdr; - libsodium = pkgs.libsodium; - sqlite3 = pkgs.sqlite; - libssh2 = pkgs.libssh2; - openssl = pkgs.openssl; - libssl = pkgs.openssl; - libcrypto = pkgs.openssl; - libstatgrab = pkgs.libstatgrab; - taglib_c = pkgs.taglib; - tdjson = pkgs.tdlib; - tensorflow = pkgs.libtensorflow; - uuid = pkgs.libossp_uuid; - "vte-2.91" = pkgs.vte; - wayland-client = if pkgs.stdenv.isDarwin then null else pkgs.wayland; - wayland-cursor = if pkgs.stdenv.isDarwin then null else pkgs.wayland; - egl = if pkgs.stdenv.isDarwin then null else pkgs.libGL; - wayland-scanner = pkgs.wayland; - wayland-server = if pkgs.stdenv.isDarwin then null else pkgs.wayland; - "webkit2gtk-4.0" = pkgs.webkitgtk; - "webkit2gtk-web-extension-4.0" = pkgs.webkitgtk; - x11 = pkgs.xorg.libX11; - xau = pkgs.xorg.libXau; - xcursor = pkgs.xorg.libXcursor; - xerces-c = pkgs.xercesc; - xext = pkgs.xorg.libXext; - xft = pkgs.xorg.libXft; - xi = pkgs.xorg.libXi; - xinerama = pkgs.xorg.libXinerama; - xkbcommon = pkgs.libxkbcommon; - xpm = pkgs.xorg.libXpm; - xrandr = pkgs.xorg.libXrandr; - xrender = pkgs.xorg.libXrender; - xscrnsaver = pkgs.xorg.libXScrnSaver; - xtst = pkgs.xorg.libXtst; - xxf86vm = pkgs.xorg.libXxf86vm; - "yaml-0.1" = pkgs.libyaml; -} + result = modulePkgs // overrides; + + data = importJSON ./pkg-config/pkg-config-data.json; + inherit (data) modules; + + modulePkgs = flip mapAttrs modules (_moduleName: moduleData: + if moduleData?attrPath then + getAttrFromPath moduleData.attrPath pkgs + else + null + ); + + overrides = { + hidapi = if pkgs.stdenv.isDarwin then pkgs.hidapi else null; + hidapi-hidraw = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; + hidapi-libusb = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; + libpulse-mainloop-glib = if pkgs.stdenv.isDarwin then null else pkgs.libpulseaudio; + wayland-client = if pkgs.stdenv.isDarwin then null else pkgs.wayland; + wayland-cursor = if pkgs.stdenv.isDarwin then null else pkgs.wayland; + egl = if pkgs.stdenv.isDarwin then null else pkgs.libGL; + wayland-server = if pkgs.stdenv.isDarwin then null else pkgs.wayland; + }; + +in + result diff --git a/pkgs/top-level/pkg-config/pkg-config-data.json b/pkgs/top-level/pkg-config/pkg-config-data.json new file mode 100644 index 000000000000..55036d91fce8 --- /dev/null +++ b/pkgs/top-level/pkg-config/pkg-config-data.json @@ -0,0 +1,940 @@ +{ + "modules": { + "IL": { + "attrPath": [ + "libdevil" + ] + }, + "ImageMagick": { + "attrPath": [ + "imagemagick" + ] + }, + "MagickWand": { + "attrPath": [ + "imagemagick" + ] + }, + "Qt5Concurrent": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Core": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5DBus": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Gui": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Network": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5OpenGL": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5OpenGLExtensions": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5PrintSupport": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Qml": { + "attrPath": [ + "qt5", + "qtdeclarative" + ] + }, + "Qt5QmlModels": { + "attrPath": [ + "qt5", + "qtdeclarative" + ] + }, + "Qt5Quick": { + "attrPath": [ + "qt5", + "qtdeclarative" + ] + }, + "Qt5QuickTest": { + "attrPath": [ + "qt5", + "qtdeclarative" + ] + }, + "Qt5QuickWidgets": { + "attrPath": [ + "qt5", + "qtdeclarative" + ] + }, + "Qt5Sql": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Test": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Widgets": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "Qt5Xml": { + "attrPath": [ + "qt5", + "qtbase" + ] + }, + "SoapySDR": { + "attrPath": [ + "soapysdr" + ] + }, + "alsa": { + "attrPath": [ + "alsa-lib" + ] + }, + "alsa-topology": { + "attrPath": [ + "alsa-lib" + ] + }, + "appindicator-0.1": { + "attrPath": [ + "libappindicator-gtk2" + ] + }, + "appindicator3-0.1": { + "attrPath": [ + "libappindicator-gtk3" + ] + }, + "bzip2": { + "attrPath": [ + "bzip2" + ] + }, + "cairo-gobject": { + "attrPath": [ + "cairo" + ] + }, + "cairo-pdf": { + "attrPath": [ + "cairo" + ] + }, + "cairo-ps": { + "attrPath": [ + "cairo" + ] + }, + "cairo-svg": { + "attrPath": [ + "cairo" + ] + }, + "dbusmenu-glib-0.4": { + "attrPath": [ + "libdbusmenu" + ] + }, + "dbusmenu-gtk3-0.4": { + "attrPath": [ + "libdbusmenu-gtk3" + ] + }, + "egl": { + "attrPath": [ + "libGL" + ] + }, + "fftw3": { + "attrPath": [ + "fftw" + ] + }, + "fftw3f": { + "attrPath": [ + "fftwFloat" + ] + }, + "form": { + "attrPath": [ + "ncurses" + ] + }, + "formw": { + "attrPath": [ + "ncurses" + ] + }, + "freealut": { + "attrPath": [ + "freealut" + ] + }, + "freetype2": { + "attrPath": [ + "freetype" + ] + }, + "gdk-2.0": { + "attrPath": [ + "gtk2" + ] + }, + "gdk-3.0": { + "attrPath": [ + "gtk3" + ] + }, + "gdk-pixbuf-2.0": { + "attrPath": [ + "gdk-pixbuf" + ] + }, + "gdk-x11-2.0": { + "attrPath": [ + "gtk2-x11" + ] + }, + "gdk-x11-3.0": { + "attrPath": [ + "gtk3-x11" + ] + }, + "geos": { + "attrPath": [ + "geos" + ] + }, + "gio-2.0": { + "attrPath": [ + "glib" + ] + }, + "gl": { + "attrPath": [ + "libGL" + ] + }, + "glew": { + "attrPath": [ + "glew" + ] + }, + "glu": { + "attrPath": [ + "libGLU" + ] + }, + "glut": { + "attrPath": [ + "freeglut" + ] + }, + "gnome-keyring-1": { + "attrPath": [ + "libgnome-keyring" + ] + }, + "gnome-vfs-2.0": { + "attrPath": [ + "gnome2", + "gnome_vfs" + ] + }, + "gnome-vfs-module-2.0": { + "attrPath": [ + "gnome2", + "gnome_vfs" + ] + }, + "gobject-2.0": { + "attrPath": [ + "glib" + ] + }, + "gobject-introspection-1.0": { + "attrPath": [ + "gobject-introspection" + ] + }, + "gstreamer-audio-1.0": { + "attrPath": [ + "gst_all_1", + "gst-plugins-base" + ] + }, + "gstreamer-base-1.0": { + "attrPath": [ + "gst_all_1", + "gst-plugins-base" + ] + }, + "gstreamer-controller-1.0": { + "attrPath": [ + "gst_all_1", + "gstreamer" + ] + }, + "gstreamer-net-1.0": { + "attrPath": [ + "gst_all_1", + "gst-plugins-base" + ] + }, + "gstreamer-video-1.0": { + "attrPath": [ + "gst_all_1", + "gst-plugins-base" + ] + }, + "gthread-2.0": { + "attrPath": [ + "glib" + ] + }, + "gtk+-2.0": { + "attrPath": [ + "gtk2" + ] + }, + "gtk+-3.0": { + "attrPath": [ + "gtk3" + ] + }, + "gtk+-x11-2.0": { + "attrPath": [ + "gtk2-x11" + ] + }, + "gtksourceview-3.0": { + "attrPath": [ + "gtksourceview3" + ] + }, + "hidapi": { + "attrPath": null + }, + "hidapi-hidraw": { + "attrPath": [ + "hidapi" + ] + }, + "hidapi-libusb": { + "attrPath": [ + "hidapi" + ] + }, + "icu-i18n": { + "attrPath": [ + "icu" + ] + }, + "icu-io": { + "attrPath": [ + "icu" + ] + }, + "icu-uc": { + "attrPath": [ + "icu" + ] + }, + "imlib2": { + "attrPath": [ + "imlib2" + ] + }, + "jack": { + "attrPath": [ + "libjack2" + ] + }, + "javascriptcoregtk-4.0": { + "attrPath": [ + "webkitgtk" + ] + }, + "lapack": { + "attrPath": [ + "liblapack" + ] + }, + "libR": { + "attrPath": [ + "R" + ] + }, + "libavutil": { + "attrPath": [ + "ffmpeg" + ] + }, + "libb2": { + "attrPath": [ + "libb2" + ] + }, + "libbrotlidec": { + "attrPath": [ + "brotli" + ] + }, + "libbrotlienc": { + "attrPath": [ + "brotli" + ] + }, + "libcrypto": { + "attrPath": [ + "openssl" + ] + }, + "libecpg": { + "attrPath": [ + "postgresql" + ] + }, + "libecpg_compat": { + "attrPath": [ + "postgresql" + ] + }, + "libgsasl": { + "attrPath": [ + "gsasl" + ] + }, + "libidn": { + "attrPath": [ + "libidn" + ] + }, + "libjpeg": { + "attrPath": [ + "libjpeg" + ] + }, + "liblzma": { + "attrPath": [ + "xz" + ] + }, + "libmagic": { + "attrPath": [ + "file" + ] + }, + "libmnl": { + "attrPath": [ + "libmnl" + ] + }, + "libnotify": { + "attrPath": [ + "libnotify" + ] + }, + "libpcap": { + "attrPath": [ + "libpcap" + ] + }, + "libpcre": { + "attrPath": [ + "pcre" + ] + }, + "libpcre2-16": { + "attrPath": [ + "pcre2" + ] + }, + "libpcre2-32": { + "attrPath": [ + "pcre2" + ] + }, + "libpcre2-8": { + "attrPath": [ + "pcre2" + ] + }, + "libpcre2-posix": { + "attrPath": [ + "pcre2" + ] + }, + "libpgtypes": { + "attrPath": [ + "postgresql" + ] + }, + "libpng": { + "attrPath": [ + "libpng" + ] + }, + "libpq": { + "attrPath": [ + "postgresql" + ] + }, + "libpulse": { + "attrPath": [ + "libpulseaudio" + ] + }, + "libpulse-mainloop-glib": { + "attrPath": [ + "libpulseaudio" + ] + }, + "libpulse-simple": { + "attrPath": [ + "libpulseaudio" + ] + }, + "libqrencode": { + "attrPath": [ + "qrencode" + ] + }, + "librtlsdr": { + "attrPath": [ + "rtl-sdr" + ] + }, + "libsass": { + "attrPath": [ + "libsass" + ] + }, + "libsctp": { + "attrPath": [ + "lksctp-tools" + ] + }, + "libsecp256k1": { + "attrPath": [ + "secp256k1" + ] + }, + "libsodium": { + "attrPath": [ + "libsodium" + ] + }, + "libsoup-gnome-2.4": { + "attrPath": [ + "libsoup" + ] + }, + "libssh2": { + "attrPath": [ + "libssh2" + ] + }, + "libssl": { + "attrPath": [ + "openssl" + ] + }, + "libstatgrab": { + "attrPath": [ + "libstatgrab" + ] + }, + "libsystemd": { + "attrPath": [ + "systemd" + ] + }, + "libturbojpeg": { + "attrPath": [ + "libjpeg" + ] + }, + "libudev": { + "attrPath": [ + "systemd" + ] + }, + "libxml-2.0": { + "attrPath": [ + "libxml2" + ] + }, + "libzip": { + "attrPath": [ + "libzip" + ] + }, + "libzmq": { + "attrPath": [ + "zeromq" + ] + }, + "m": { + "attrPath": null + }, + "menu": { + "attrPath": [ + "ncurses" + ] + }, + "menuw": { + "attrPath": [ + "ncurses" + ] + }, + "ncurses": { + "attrPath": [ + "ncurses" + ] + }, + "ncurses++": { + "attrPath": [ + "ncurses" + ] + }, + "ncurses++w": { + "attrPath": [ + "ncurses" + ] + }, + "ncursesw": { + "attrPath": [ + "ncurses" + ] + }, + "netsnmp": { + "attrPath": [ + "net_snmp" + ] + }, + "nix-cmd": { + "attrPath": [ + "nix" + ] + }, + "nix-expr": { + "attrPath": [ + "nix" + ] + }, + "nix-main": { + "attrPath": [ + "nix" + ] + }, + "nix-store": { + "attrPath": [ + "nix" + ] + }, + "odbc": { + "attrPath": [ + "unixODBC" + ] + }, + "ompi": { + "attrPath": [ + "openmpi" + ] + }, + "ompi-c": { + "attrPath": [ + "openmpi" + ] + }, + "ompi-cxx": { + "attrPath": [ + "openmpi" + ] + }, + "ompi-f77": { + "attrPath": [ + "openmpi" + ] + }, + "ompi-f90": { + "attrPath": [ + "openmpi" + ] + }, + "ompi-fort": { + "attrPath": [ + "openmpi" + ] + }, + "openblas": { + "attrPath": [ + "openblasCompat" + ] + }, + "openssl": { + "attrPath": [ + "openssl" + ] + }, + "orte": { + "attrPath": [ + "openmpi" + ] + }, + "panel": { + "attrPath": [ + "ncurses" + ] + }, + "panelw": { + "attrPath": [ + "ncurses" + ] + }, + "pangocairo": { + "attrPath": [ + "pango" + ] + }, + "poppler-glib": { + "attrPath": [ + "poppler_gi" + ] + }, + "pthread": { + "attrPath": null + }, + "python": { + "attrPath": [ + "python3" + ] + }, + "ruby-2.7": { + "attrPath": [ + "ruby_2_7" + ] + }, + "ruby-3.0": { + "attrPath": [ + "ruby_3_0" + ] + }, + "ruby-3.1": { + "attrPath": [ + "ruby_3_1" + ] + }, + "sdl2": { + "attrPath": [ + "SDL2" + ] + }, + "sndfile": { + "attrPath": [ + "libsndfile" + ] + }, + "sqlite3": { + "attrPath": [ + "sqlite" + ] + }, + "taglib": { + "attrPath": [ + "taglib" + ] + }, + "taglib_c": { + "attrPath": [ + "taglib" + ] + }, + "tdjson": { + "attrPath": [ + "tdlib" + ] + }, + "tensorflow": { + "attrPath": [ + "libtensorflow" + ] + }, + "uuid": { + "attrPath": [ + "libossp_uuid" + ] + }, + "vte-2.91": { + "attrPath": [ + "vte" + ] + }, + "wayland-client": { + "attrPath": [ + "wayland" + ] + }, + "wayland-cursor": { + "attrPath": [ + "wayland" + ] + }, + "wayland-scanner": { + "attrPath": [ + "wayland" + ] + }, + "wayland-server": { + "attrPath": [ + "wayland" + ] + }, + "webkit2gtk-4.0": { + "attrPath": [ + "webkitgtk" + ] + }, + "webkit2gtk-web-extension-4.0": { + "attrPath": [ + "webkitgtk" + ] + }, + "x11": { + "attrPath": [ + "xorg", + "libX11" + ] + }, + "xau": { + "attrPath": [ + "xorg", + "libXau" + ] + }, + "xcursor": { + "attrPath": [ + "xorg", + "libXcursor" + ] + }, + "xerces-c": { + "attrPath": [ + "xercesc" + ] + }, + "xext": { + "attrPath": [ + "xorg", + "libXext" + ] + }, + "xft": { + "attrPath": [ + "xorg", + "libXft" + ] + }, + "xi": { + "attrPath": [ + "xorg", + "libXi" + ] + }, + "xinerama": { + "attrPath": [ + "xorg", + "libXinerama" + ] + }, + "xkbcommon": { + "attrPath": [ + "libxkbcommon" + ] + }, + "xpm": { + "attrPath": [ + "xorg", + "libXpm" + ] + }, + "xrandr": { + "attrPath": [ + "xorg", + "libXrandr" + ] + }, + "xrender": { + "attrPath": [ + "xorg", + "libXrender" + ] + }, + "xscrnsaver": { + "attrPath": [ + "xorg", + "libXScrnSaver" + ] + }, + "xtst": { + "attrPath": [ + "xorg", + "libXtst" + ] + }, + "xxf86vm": { + "attrPath": [ + "xorg", + "libXxf86vm" + ] + }, + "yaml-0.1": { + "attrPath": [ + "libyaml" + ] + }, + "zlib": { + "attrPath": [ + "zlib" + ] + } + } +} -- cgit v1.2.3 From 09eb09b9c50d4f44082a7843b1222bfbaa2d7887 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Jan 2023 08:37:51 +0100 Subject: pkg-config-data.json: Encode platform support --- pkgs/top-level/pkg-config-packages.nix | 29 +++++++++--------- pkgs/top-level/pkg-config/pkg-config-data.json | 42 +++++++++++++++++++++----- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/pkgs/top-level/pkg-config-packages.nix b/pkgs/top-level/pkg-config-packages.nix index 8d428cfb2182..b5cda4939156 100644 --- a/pkgs/top-level/pkg-config-packages.nix +++ b/pkgs/top-level/pkg-config-packages.nix @@ -13,34 +13,33 @@ pkgs: let inherit (pkgs) lib; inherit (lib) + all flip mapAttrs + mapAttrsToList getAttrFromPath importJSON ; - result = modulePkgs // overrides; - data = importJSON ./pkg-config/pkg-config-data.json; inherit (data) modules; + platform = pkgs.stdenv.hostPlatform; + + isSupported = moduleData: + moduleData?supportedWhenPlatformAttrsEqual -> + all (x: x) ( + mapAttrsToList + (k: v: platform?${k} && platform.${k} == v) + moduleData.supportedWhenPlatformAttrsEqual + ); + modulePkgs = flip mapAttrs modules (_moduleName: moduleData: - if moduleData?attrPath then + if moduleData?attrPath && isSupported moduleData then getAttrFromPath moduleData.attrPath pkgs else null ); - overrides = { - hidapi = if pkgs.stdenv.isDarwin then pkgs.hidapi else null; - hidapi-hidraw = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; - hidapi-libusb = if pkgs.stdenv.isDarwin then null else pkgs.hidapi; - libpulse-mainloop-glib = if pkgs.stdenv.isDarwin then null else pkgs.libpulseaudio; - wayland-client = if pkgs.stdenv.isDarwin then null else pkgs.wayland; - wayland-cursor = if pkgs.stdenv.isDarwin then null else pkgs.wayland; - egl = if pkgs.stdenv.isDarwin then null else pkgs.libGL; - wayland-server = if pkgs.stdenv.isDarwin then null else pkgs.wayland; - }; - in - result + modulePkgs diff --git a/pkgs/top-level/pkg-config/pkg-config-data.json b/pkgs/top-level/pkg-config/pkg-config-data.json index 55036d91fce8..c0b6e49b48a0 100644 --- a/pkgs/top-level/pkg-config/pkg-config-data.json +++ b/pkgs/top-level/pkg-config/pkg-config-data.json @@ -180,7 +180,10 @@ "egl": { "attrPath": [ "libGL" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "fftw3": { "attrPath": [ @@ -350,17 +353,28 @@ ] }, "hidapi": { - "attrPath": null + "attrPath": [ + "hidapi" + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": true + } }, "hidapi-hidraw": { "attrPath": [ "hidapi" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "hidapi-libusb": { "attrPath": [ "hidapi" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "icu-i18n": { "attrPath": [ @@ -525,7 +539,10 @@ "libpulse-mainloop-glib": { "attrPath": [ "libpulseaudio" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "libpulse-simple": { "attrPath": [ @@ -811,12 +828,18 @@ "wayland-client": { "attrPath": [ "wayland" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "wayland-cursor": { "attrPath": [ "wayland" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "wayland-scanner": { "attrPath": [ @@ -826,7 +849,10 @@ "wayland-server": { "attrPath": [ "wayland" - ] + ], + "supportedWhenPlatformAttrsEqual": { + "isDarwin": false + } }, "webkit2gtk-4.0": { "attrPath": [ -- cgit v1.2.3 From 811bf8ade022b34148a5b71242ca1a713865c7fa Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Jan 2023 08:41:23 +0100 Subject: pkg-config-data.json: Add version --- pkgs/top-level/pkg-config/pkg-config-data.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/top-level/pkg-config/pkg-config-data.json b/pkgs/top-level/pkg-config/pkg-config-data.json index c0b6e49b48a0..ba8d6e7b821e 100644 --- a/pkgs/top-level/pkg-config/pkg-config-data.json +++ b/pkgs/top-level/pkg-config/pkg-config-data.json @@ -1,4 +1,8 @@ { + "version": { + "major": 0, + "minor": 1 + }, "modules": { "IL": { "attrPath": [ -- cgit v1.2.3 From 3be7ea8c891b3209e92e961fe689649fb0333bcc Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Jan 2023 08:54:13 +0100 Subject: top-level/pkg-config: Make tests easy to find --- pkgs/test/default.nix | 17 +---- pkgs/test/pkg-config-packages.nix | 81 --------------------- pkgs/top-level/all-packages.nix | 2 +- pkgs/top-level/pkg-config-packages.nix | 45 ------------ .../pkg-config/defaultPkgConfigPackages.nix | 45 ++++++++++++ .../pkg-config/test-defaultPkgConfigPackages.nix | 83 ++++++++++++++++++++++ pkgs/top-level/pkg-config/tests.nix | 21 ++++++ 7 files changed, 151 insertions(+), 143 deletions(-) delete mode 100644 pkgs/test/pkg-config-packages.nix delete mode 100644 pkgs/top-level/pkg-config-packages.nix create mode 100644 pkgs/top-level/pkg-config/defaultPkgConfigPackages.nix create mode 100644 pkgs/top-level/pkg-config/test-defaultPkgConfigPackages.nix create mode 100644 pkgs/top-level/pkg-config/tests.nix diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 72b22f7f6865..39039c5950e4 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -51,22 +51,7 @@ with pkgs; php = recurseIntoAttrs (callPackages ./php {}); - defaultPkgConfigPackages = - let - # defaultPkgConfigPackages test needs a Nixpkgs with allowUnsupportedPlatform - # in order to filter out the unsupported packages without throwing any errors - # tryEval would be too fragile, masking different problems as if they're - # unsupported platform problems. - allPkgs = import ../top-level { - system = pkgs.stdenv.hostPlatform.system; - localSystem = pkgs.stdenv.hostPlatform.system; - config = { - allowUnsupportedSystem = true; - }; - overlays = []; - }; - in - allPkgs.callPackage ./pkg-config-packages.nix { }; + pkg-config = recurseIntoAttrs (callPackage ../top-level/pkg-config/tests.nix { }); rustCustomSysroot = callPackage ./rust-sysroot {}; buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { }; diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix deleted file mode 100644 index 8cb6cc57753f..000000000000 --- a/pkgs/test/pkg-config-packages.nix +++ /dev/null @@ -1,81 +0,0 @@ -{ lib, pkg-config, defaultPkgConfigPackages, runCommand }: -let - inherit (lib.strings) escapeNixIdentifier; - - allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) defaultPkgConfigPackages; - - # nix-build rejects attribute names with periods - # This will build those regardless. - tests-combined = runCommand "pkg-config-checks" { - allTests = lib.attrValues allTests; - } '' - touch $out - ''; - - makePkgConfigTestMaybe = moduleName: pkg: - if ! lib.isDerivation pkg - then - throw "pkg-config module `${escapeNixIdentifier moduleName}` is not defined to be a derivation. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs." - - else if ! pkg?meta.unsupported - then - throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.unsupported` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs." - - else if pkg.meta.unsupported - then - # We return `null` instead of doing a `filterAttrs`, because with - # `filterAttrs` the evaluator would not be able to return the attribute - # set without first evaluating all of the attribute _values_. This would - # be rather expensive, and severly slow down the use case of getting a - # single test, which we want to do in `passthru.tests`, or interactively. - null - - else if ! pkg?meta.broken - then - throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.broken` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config.packages.nix` in Nixpkgs." - - else if pkg.meta.broken - then null - - else makePkgConfigTest moduleName pkg; - - makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" { - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ pkg ]; - inherit moduleName; - meta = { - description = "Test whether ${pkg.name} exposes pkg-config module ${moduleName}"; - } - # Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org, - # as hydra can't check this meta info in dependencies. - # The test itself is just Nixpkgs, with MIT license. - // builtins.intersectAttrs - { - available = throw "unused"; - broken = throw "unused"; - insecure = throw "unused"; - license = throw "unused"; - maintainers = throw "unused"; - platforms = throw "unused"; - unfree = throw "unused"; - unsupported = throw "unused"; - } - pkg.meta; - } '' - echo "checking pkg-config module $moduleName in $buildInputs" - set +e - version="$(pkg-config --modversion $moduleName)" - r=$? - set -e - if [[ $r = 0 ]]; then - echo "✅ pkg-config module $moduleName exists and has version $version" - echo "$version" > $out - else - echo "These modules were available in the input propagation closure:" - pkg-config --list-all - echo "❌ pkg-config module $moduleName was not found" - false - fi - ''; -in - allTests // { inherit tests-combined; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cde388312abf..1638192c33df 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -112,7 +112,7 @@ with pkgs; tests = callPackages ../test {}; - defaultPkgConfigPackages = import ./pkg-config-packages.nix pkgs; + defaultPkgConfigPackages = import ./pkg-config/defaultPkgConfigPackages.nix pkgs; ### Nixpkgs maintainer tools diff --git a/pkgs/top-level/pkg-config-packages.nix b/pkgs/top-level/pkg-config-packages.nix deleted file mode 100644 index b5cda4939156..000000000000 --- a/pkgs/top-level/pkg-config-packages.nix +++ /dev/null @@ -1,45 +0,0 @@ -/* A set of aliases to be used in generated expressions. - - In case of ambiguity, this will pick a sensible default. - - This was initially based on cabal2nix's mapping. - - It'd be nice to generate this mapping, based on a set of derivations. - It can not be fully automated, so it should be a expression or tool - that makes suggestions about which pkg-config module names can be added. - */ -pkgs: - -let - inherit (pkgs) lib; - inherit (lib) - all - flip - mapAttrs - mapAttrsToList - getAttrFromPath - importJSON - ; - - data = importJSON ./pkg-config/pkg-config-data.json; - inherit (data) modules; - - platform = pkgs.stdenv.hostPlatform; - - isSupported = moduleData: - moduleData?supportedWhenPlatformAttrsEqual -> - all (x: x) ( - mapAttrsToList - (k: v: platform?${k} && platform.${k} == v) - moduleData.supportedWhenPlatformAttrsEqual - ); - - modulePkgs = flip mapAttrs modules (_moduleName: moduleData: - if moduleData?attrPath && isSupported moduleData then - getAttrFromPath moduleData.attrPath pkgs - else - null - ); - -in - modulePkgs diff --git a/pkgs/top-level/pkg-config/defaultPkgConfigPackages.nix b/pkgs/top-level/pkg-config/defaultPkgConfigPackages.nix new file mode 100644 index 000000000000..b3cf3cdca2fc --- /dev/null +++ b/pkgs/top-level/pkg-config/defaultPkgConfigPackages.nix @@ -0,0 +1,45 @@ +/* A set of aliases to be used in generated expressions. + + In case of ambiguity, this will pick a sensible default. + + This was initially based on cabal2nix's mapping. + + It'd be nice to generate this mapping, based on a set of derivations. + It can not be fully automated, so it should be a expression or tool + that makes suggestions about which pkg-config module names can be added. + */ +pkgs: + +let + inherit (pkgs) lib; + inherit (lib) + all + flip + mapAttrs + mapAttrsToList + getAttrFromPath + importJSON + ; + + data = importJSON ./pkg-config-data.json; + inherit (data) modules; + + platform = pkgs.stdenv.hostPlatform; + + isSupported = moduleData: + moduleData?supportedWhenPlatformAttrsEqual -> + all (x: x) ( + mapAttrsToList + (k: v: platform?${k} && platform.${k} == v) + moduleData.supportedWhenPlatformAttrsEqual + ); + + modulePkgs = flip mapAttrs modules (_moduleName: moduleData: + if moduleData?attrPath && isSupported moduleData then + getAttrFromPath moduleData.attrPath pkgs + else + null + ); + +in + modulePkgs diff --git a/pkgs/top-level/pkg-config/test-defaultPkgConfigPackages.nix b/pkgs/top-level/pkg-config/test-defaultPkgConfigPackages.nix new file mode 100644 index 000000000000..e34e1435c3c5 --- /dev/null +++ b/pkgs/top-level/pkg-config/test-defaultPkgConfigPackages.nix @@ -0,0 +1,83 @@ +# cd nixpkgs +# nix-build -A tests.pkg-config.defaultPkgConfigPackages +{ lib, pkg-config, defaultPkgConfigPackages, runCommand }: +let + inherit (lib.strings) escapeNixIdentifier; + + allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) defaultPkgConfigPackages; + + # nix-build rejects attribute names with periods + # This will build those regardless. + tests-combined = runCommand "pkg-config-checks" { + allTests = lib.attrValues allTests; + } '' + touch $out + ''; + + makePkgConfigTestMaybe = moduleName: pkg: + if ! lib.isDerivation pkg + then + throw "pkg-config module `${escapeNixIdentifier moduleName}` is not defined to be a derivation. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs." + + else if ! pkg?meta.unsupported + then + throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.unsupported` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs." + + else if pkg.meta.unsupported + then + # We return `null` instead of doing a `filterAttrs`, because with + # `filterAttrs` the evaluator would not be able to return the attribute + # set without first evaluating all of the attribute _values_. This would + # be rather expensive, and severly slow down the use case of getting a + # single test, which we want to do in `passthru.tests`, or interactively. + null + + else if ! pkg?meta.broken + then + throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.broken` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config.packages.nix` in Nixpkgs." + + else if pkg.meta.broken + then null + + else makePkgConfigTest moduleName pkg; + + makeP