1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-09 17:46:29 +09:00

lib.meta.availableOn: Return false if pkg parameter is null

To fix overriding packages that checks for platform compatibility, like pipewire.

`pipewire` contains the following logic to enable support for ldac depending on library platform compatibility:
```nix
ldacbtSupport = lib.meta.availableOn stdenv.hostPlatform ldacbt
```

Which is used later in the expression to create a Meson flag:
```nix
(lib.mesonEnable "bluez5-codec-ldac" (bluezSupport && ldacbtSupport))
```

This means that attempting to build `pipewire` without `ldacbt` like:
```nix
pipewire.override {
  ldacbt = null;
}
```
will fail because the the Meson flag indicates the feature should be enabled, but the library is passed to `buildInputs` as `null`.
This commit is contained in:
adisbladis 2025-05-02 18:20:17 +02:00
parent 4ad8dfd97d
commit 9338d924db

View file

@ -289,7 +289,8 @@ rec {
*/
availableOn =
platform: pkg:
((!pkg ? meta.platforms) || any (platformMatch platform) pkg.meta.platforms)
pkg != null
&& ((!pkg ? meta.platforms) || any (platformMatch platform) pkg.meta.platforms)
&& all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or [ ]);
/**