mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +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" ```
98 lines
2.2 KiB
Nix
98 lines
2.2 KiB
Nix
{ config
|
|
, lib
|
|
, stdenv
|
|
, fetchFromGitHub
|
|
, cmake
|
|
, macdylibbundler
|
|
, makeWrapper
|
|
, darwin
|
|
, codec2
|
|
, libpulseaudio
|
|
, libsamplerate
|
|
, libsndfile
|
|
, lpcnetfreedv
|
|
, portaudio
|
|
, speexdsp
|
|
, hamlib_4
|
|
, wxGTK32
|
|
, sioclient
|
|
, pulseSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux
|
|
, AppKit
|
|
, AVFoundation
|
|
, Cocoa
|
|
, CoreMedia
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "freedv";
|
|
version = "1.9.9.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "drowe67";
|
|
repo = "freedv-gui";
|
|
rev = "v${version}";
|
|
hash = "sha256-oFuAH81mduiSQGIDgDDy1IPskqqCBmfWbpqQstUIw9g=";
|
|
};
|
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
substituteInPlace CMakeLists.txt \
|
|
--replace-fail "-Wl,-ld_classic" ""
|
|
substituteInPlace src/CMakeLists.txt \
|
|
--replace-fail "\''${CMAKE_SOURCE_DIR}/macdylibbundler/dylibbundler" "dylibbundler"
|
|
sed -i "/codesign/d;/hdiutil/d" src/CMakeLists.txt
|
|
'';
|
|
|
|
nativeBuildInputs = [
|
|
cmake
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
macdylibbundler
|
|
makeWrapper
|
|
darwin.autoSignDarwinBinariesHook
|
|
];
|
|
|
|
buildInputs = [
|
|
codec2
|
|
libsamplerate
|
|
libsndfile
|
|
lpcnetfreedv
|
|
speexdsp
|
|
hamlib_4
|
|
wxGTK32
|
|
sioclient
|
|
] ++ (if pulseSupport then [ libpulseaudio ] else [ portaudio ])
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
AppKit
|
|
AVFoundation
|
|
Cocoa
|
|
CoreMedia
|
|
];
|
|
|
|
cmakeFlags = [
|
|
"-DUSE_INTERNAL_CODEC2:BOOL=FALSE"
|
|
"-DUSE_STATIC_DEPS:BOOL=FALSE"
|
|
"-DUNITTEST=ON"
|
|
"-DUSE_PULSEAUDIO:BOOL=${if pulseSupport then "TRUE" else "FALSE"}"
|
|
];
|
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
|
|
"-DAPPLE_OLD_XCODE"
|
|
]);
|
|
|
|
doCheck = true;
|
|
|
|
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
mkdir -p $out/Applications
|
|
mv $out/bin/FreeDV.app $out/Applications
|
|
makeWrapper $out/Applications/FreeDV.app/Contents/MacOS/FreeDV $out/bin/freedv
|
|
'';
|
|
|
|
meta = with lib; {
|
|
homepage = "https://freedv.org/";
|
|
description = "Digital voice for HF radio";
|
|
license = licenses.lgpl21;
|
|
maintainers = with maintainers; [ mvs wegank ];
|
|
platforms = platforms.unix;
|
|
mainProgram = "freedv";
|
|
};
|
|
}
|