Merge pull request #114374 from oxalica/lib/platform-support-check

lib.meta: introduce `availableOn` to check package availability on given platform

Changed files
+27 -15
lib
nixos
modules
system
boot
pkgs
development
compilers
libraries
wiredtiger
misc
os-specific
linux
apparmor
systemd
servers
shishi
tools
misc
package-management
+12
lib/meta.nix
···
then { system = elem; }
else { parsed = elem; };
in lib.matchAttrs pattern platform;
+
+
/* Check if a package is available on a given platform.
+
+
A package is available on a platform if both
+
+
1. One of `meta.platforms` pattern matches the given platform.
+
+
2. None of `meta.badPlatforms` pattern matches the given platform.
+
*/
+
availableOn = platform: pkg:
+
lib.any (platformMatch platform) pkg.meta.platforms &&
+
lib.all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
}
+1 -1
nixos/modules/system/boot/kexec.nix
···
{ pkgs, lib, ... }:
{
-
config = lib.mkIf (lib.any (lib.meta.platformMatch pkgs.stdenv.hostPlatform) pkgs.kexectools.meta.platforms) {
+
config = lib.mkIf (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.kexectools) {
environment.systemPackages = [ pkgs.kexectools ];
systemd.services.prepare-kexec =
+1 -1
pkgs/development/compilers/ghc/8.10.4.nix
···
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
-
enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
, # If enabled, use -fPIC when compiling static libs.
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+1 -1
pkgs/development/compilers/ghc/8.8.4.nix
···
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
-
enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
, # If enabled, use -fPIC when compiling static libs.
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+1 -1
pkgs/development/compilers/ghc/9.0.1.nix
···
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
-
enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
, # If enabled, use -fPIC when compiling static libs.
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+1 -1
pkgs/development/compilers/ghc/head.nix
···
, # If enabled, GHC will be built with the GPL-free but slightly slower native
# bignum backend instead of the faster but GPLed gmp backend.
-
enableNativeBignum ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms)
+
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
, gmp
, # If enabled, use -fPIC when compiling static libs.
+1 -1
pkgs/development/libraries/wiredtiger/default.nix
···
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
-
shouldUsePkg = pkg: if pkg != null && lib.any (lib.meta.platformMatch stdenv.hostPlatform) pkg.meta.platforms then pkg else null;
+
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optLz4 = shouldUsePkg lz4;
optSnappy = shouldUsePkg snappy;
+1 -1
pkgs/misc/jackaudio/default.nix
···
with lib;
let
inherit (python3Packages) python dbus-python;
-
shouldUsePkg = pkg: if pkg != null && lib.any (lib.meta.platformMatch stdenv.hostPlatform) pkg.meta.platforms then pkg else null;
+
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
libOnly = prefix == "lib";
+1 -1
pkgs/misc/jackaudio/jack1.nix
···
}:
let
-
shouldUsePkg = pkg: if pkg != null && lib.any (lib.meta.platformMatch stdenv.hostPlatform) pkg.meta.platforms then pkg else null;
+
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optAlsaLib = shouldUsePkg alsaLib;
optDb = shouldUsePkg db;
+2 -2
pkgs/os-specific/linux/apparmor/default.nix
···
, flex, bison
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
, gawk
-
, withPerl ? stdenv.hostPlatform == stdenv.buildPlatform && lib.any (lib.meta.platformMatch stdenv.hostPlatform) perl.meta.platforms, perl
-
, withPython ? stdenv.hostPlatform == stdenv.buildPlatform && lib.any (lib.meta.platformMatch stdenv.hostPlatform) python.meta.platforms, python
+
, withPerl ? stdenv.hostPlatform == stdenv.buildPlatform && lib.meta.availableOn stdenv.hostPlatform perl, perl
+
, withPython ? stdenv.hostPlatform == stdenv.buildPlatform && lib.meta.availableOn stdenv.hostPlatform python, python
, swig
, ncurses
, pam
+2 -2
pkgs/os-specific/linux/systemd/default.nix
···
, iptables
, withSelinux ? false
, libselinux
-
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms
+
, withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp
, libseccomp
-
, withKexectools ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) kexectools.meta.platforms
+
, withKexectools ? lib.meta.availableOn stdenv.hostPlatform kexectools
, kexectools
, bashInteractive
, libmicrohttpd
+1 -1
pkgs/servers/shishi/default.nix
···
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
-
shouldUsePkg = pkg: if pkg != null && lib.any (lib.meta.platformMatch stdenv.hostPlatform) pkg.meta.platforms then pkg else null;
+
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optPam = shouldUsePkg pam;
optLibidn = shouldUsePkg libidn;
+1 -1
pkgs/tools/misc/tlp/default.nix
···
systemd
util-linux
] ++ lib.optional enableRDW networkmanager
-
++ lib.optional (lib.any (lib.meta.platformMatch stdenv.hostPlatform) x86_energy_perf_policy.meta.platforms) x86_energy_perf_policy
+
++ lib.optional (lib.meta.availableOn stdenv.hostPlatform x86_energy_perf_policy) x86_energy_perf_policy
);
in
''
+1 -1
pkgs/tools/package-management/nix/default.nix
···
, storeDir
, stateDir
, confDir
-
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
+
, withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp, libseccomp
, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
, enableStatic ? stdenv.hostPlatform.isStatic
, pname, version, suffix ? "", src