nixpkgs/pkgs/by-name/vo/volk_2/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
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"
```
2024-09-25 00:04:37 +03:00

68 lines
2.0 KiB
Nix

{
stdenv,
lib,
fetchFromGitHub,
cmake,
python311,
enableModTool ? true,
removeReferencesTo,
fetchpatch,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "volk";
# Version 2.5.1 seems to cause a build issue for aarch64-darwin[1], and for
# gnuradio 3.8 on all platforms[2]. Hence we pin this package to 2.5.0 and
# use it for GR 3.8 for all platforms.
#
# [1]: https://github.com/NixOS/nixpkgs/pull/160152#issuecomment-1043380478A
# [2]: https://github.com/NixOS/nixpkgs/pull/330477#issuecomment-2254477735
version = "2.5.0";
src = fetchFromGitHub {
owner = "gnuradio";
repo = "volk";
rev = "v${finalAttrs.version}";
hash = "sha256-XvX6emv30bSB29EFm6aC+j8NGOxWqHCNv0Hxtdrq/jc=";
fetchSubmodules = true;
};
patches = [
(fetchpatch {
url = "https://raw.githubusercontent.com/macports/macports-ports/e83a55ef196d4283be438c052295b2fc44f3df5b/science/volk/files/patch-cpu_features-add-support-for-ARM64.diff";
hash = "sha256-MNUntVvKZC4zuQsxGQCItaUaaQ1d31re2qjyPFbySmI=";
extraPrefix = "";
})
];
cmakeFlags =
[ (lib.cmakeBool "ENABLE_MODTOOL" enableModTool) ]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
# offset 14335 in1: -1.03372 in2: -1.03371 tolerance was: 1e-05
# volk_32f_log2_32f: fail on arch neon
"-DCMAKE_CTEST_ARGUMENTS=--exclude-regex;qa_volk_32f_log2_32f"
];
postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
remove-references-to -t ${stdenv.cc} $(readlink -f $out/lib/libvolk.so)
'';
nativeBuildInputs = [
cmake
# This version of the project wasn't updated to use Python 3.12 which
# doesn't include the deprecated distutils module.
python311
python311.pkgs.mako
removeReferencesTo
];
doCheck = true;
meta = {
homepage = "http://libvolk.org/";
description = "Vector Optimized Library of Kernels (version 2.5.0 - for GR 3.8)";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ doronbehar ];
};
})