lib.meta: introduce `availableOn`
This commit is contained in:
parent
905ecb920e
commit
354d262db8
12
lib/meta.nix
12
lib/meta.nix
|
@ -87,4 +87,16 @@ rec {
|
||||||
then { system = elem; }
|
then { system = elem; }
|
||||||
else { parsed = elem; };
|
else { parsed = elem; };
|
||||||
in lib.matchAttrs pattern platform;
|
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,7 +1,7 @@
|
||||||
{ pkgs, lib, ... }:
|
{ 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 ];
|
environment.systemPackages = [ pkgs.kexectools ];
|
||||||
|
|
||||||
systemd.services.prepare-kexec =
|
systemd.services.prepare-kexec =
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
||||||
# library instead of the faster but GPLed integer-gmp library.
|
# 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.
|
, # If enabled, use -fPIC when compiling static libs.
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
||||||
# library instead of the faster but GPLed integer-gmp library.
|
# 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.
|
, # If enabled, use -fPIC when compiling static libs.
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
||||||
# library instead of the faster but GPLed integer-gmp library.
|
# 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.
|
, # If enabled, use -fPIC when compiling static libs.
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
# 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
|
, gmp
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
, # If enabled, use -fPIC when compiling static libs.
|
||||||
|
|
|
@ -14,7 +14,7 @@ let
|
||||||
mkEnable = mkFlag "enable-" "disable-";
|
mkEnable = mkFlag "enable-" "disable-";
|
||||||
mkWith = mkFlag "with-" "without-";
|
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;
|
optLz4 = shouldUsePkg lz4;
|
||||||
optSnappy = shouldUsePkg snappy;
|
optSnappy = shouldUsePkg snappy;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
inherit (python3Packages) python dbus-python;
|
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";
|
libOnly = prefix == "lib";
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
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;
|
optAlsaLib = shouldUsePkg alsaLib;
|
||||||
optDb = shouldUsePkg db;
|
optDb = shouldUsePkg db;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
, flex, bison
|
, flex, bison
|
||||||
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
||||||
, gawk
|
, gawk
|
||||||
, withPerl ? stdenv.hostPlatform == stdenv.buildPlatform && lib.any (lib.meta.platformMatch stdenv.hostPlatform) perl.meta.platforms, perl
|
, withPerl ? stdenv.hostPlatform == stdenv.buildPlatform && lib.meta.availableOn stdenv.hostPlatform perl, perl
|
||||||
, withPython ? stdenv.hostPlatform == stdenv.buildPlatform && lib.any (lib.meta.platformMatch stdenv.hostPlatform) python.meta.platforms, python
|
, withPython ? stdenv.hostPlatform == stdenv.buildPlatform && lib.meta.availableOn stdenv.hostPlatform python, python
|
||||||
, swig
|
, swig
|
||||||
, ncurses
|
, ncurses
|
||||||
, pam
|
, pam
|
||||||
|
|
|
@ -51,9 +51,9 @@
|
||||||
, iptables
|
, iptables
|
||||||
, withSelinux ? false
|
, withSelinux ? false
|
||||||
, libselinux
|
, libselinux
|
||||||
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms
|
, withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp
|
||||||
, libseccomp
|
, libseccomp
|
||||||
, withKexectools ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) kexectools.meta.platforms
|
, withKexectools ? lib.meta.availableOn stdenv.hostPlatform kexectools
|
||||||
, kexectools
|
, kexectools
|
||||||
, bashInteractive
|
, bashInteractive
|
||||||
, libmicrohttpd
|
, libmicrohttpd
|
||||||
|
|
|
@ -14,7 +14,7 @@ let
|
||||||
mkWith = mkFlag "with-" "without-";
|
mkWith = mkFlag "with-" "without-";
|
||||||
mkOther = mkFlag "" "" true;
|
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;
|
optPam = shouldUsePkg pam;
|
||||||
optLibidn = shouldUsePkg libidn;
|
optLibidn = shouldUsePkg libidn;
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
systemd
|
systemd
|
||||||
util-linux
|
util-linux
|
||||||
] ++ lib.optional enableRDW networkmanager
|
] ++ 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
|
in
|
||||||
''
|
''
|
||||||
|
|
|
@ -21,7 +21,7 @@ common =
|
||||||
, storeDir
|
, storeDir
|
||||||
, stateDir
|
, stateDir
|
||||||
, confDir
|
, 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
|
, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
|
||||||
, enableStatic ? stdenv.hostPlatform.isStatic
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
||||||
, name, suffix ? "", src
|
, name, suffix ? "", src
|
||||||
|
|
Loading…
Reference in New Issue