mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
70 lines
1.5 KiB
Nix
70 lines
1.5 KiB
Nix
{ lib, stdenv, fetchFromGitHub
|
|
, cmake
|
|
, pkg-config
|
|
, alsa-lib
|
|
, jack2
|
|
, libpulseaudio
|
|
, sndio
|
|
, speexdsp
|
|
, AudioUnit
|
|
, CoreAudio
|
|
, CoreServices
|
|
, lazyLoad ? !stdenv.hostPlatform.isDarwin
|
|
}:
|
|
|
|
assert lib.assertMsg (stdenv.hostPlatform.isDarwin -> !lazyLoad) "cubeb: lazyLoad is inert on Darwin";
|
|
|
|
let
|
|
backendLibs = [
|
|
alsa-lib
|
|
jack2
|
|
libpulseaudio
|
|
sndio
|
|
];
|
|
|
|
in stdenv.mkDerivation {
|
|
pname = "cubeb";
|
|
version = "unstable-2022-10-18";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "mozilla";
|
|
repo = "cubeb";
|
|
rev = "27d2a102b0b75d9e49d43bc1ea516233fb87d778";
|
|
hash = "sha256-q+uz1dGU4LdlPogL1nwCR/KuOX4Oy3HhMdA6aJylBRk=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
cmake
|
|
pkg-config
|
|
];
|
|
|
|
buildInputs = [ speexdsp ] ++ (
|
|
if stdenv.hostPlatform.isDarwin then [ AudioUnit CoreAudio CoreServices ]
|
|
else backendLibs
|
|
);
|
|
|
|
cmakeFlags = [
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
"-DBUILD_TESTS=OFF" # tests require an audio server
|
|
"-DBUNDLE_SPEEX=OFF"
|
|
"-DUSE_SANITIZERS=OFF"
|
|
|
|
# Whether to lazily load libraries with dlopen()
|
|
"-DLAZY_LOAD_LIBS=${if lazyLoad then "ON" else "OFF"}"
|
|
];
|
|
|
|
passthru = {
|
|
# For downstream users when lazyLoad is true
|
|
backendLibs = lib.optionals lazyLoad backendLibs;
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "Cross platform audio library";
|
|
mainProgram = "cubeb-test";
|
|
homepage = "https://github.com/mozilla/cubeb";
|
|
license = licenses.isc;
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
maintainers = with maintainers; [ zhaofengli ];
|
|
};
|
|
}
|