nixpkgs/pkgs/by-name/nv/nvidia-texture-tools/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

51 lines
1.2 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, cmake
}:
stdenv.mkDerivation {
pname = "nvidia-texture-tools";
version = "2.1.2-unstable-2020-12-21";
src = fetchFromGitHub {
owner = "castano";
repo = "nvidia-texture-tools";
rev = "aeddd65f81d36d8cb7b169b469ef25156666077e";
hash = "sha256-BYNm8CxPQbfmnnzNmOQ2Dc8HSyO8mkqzYsBZ5T80398=";
};
postPatch = ''
# Make a recently added pure virtual function just virtual,
# to keep compatibility.
sed -i 's/virtual void endImage() = 0;/virtual void endImage() {}/' src/nvtt/nvtt.h
'' + lib.optionalString stdenv.hostPlatform.isAarch64 ''
# remove x86_64-only libraries
sed -i '/bc1enc/d' src/nvtt/tests/CMakeLists.txt
sed -i '/libsquish/d;/CMP_Core/d' extern/CMakeLists.txt
'';
outputs = [ "out" "dev" "lib" ];
nativeBuildInputs = [
cmake
];
cmakeFlags = [
(lib.cmakeBool "NVTT_SHARED" true)
];
postInstall = ''
moveToOutput include "$dev"
moveToOutput lib "$lib"
'';
meta = with lib; {
description = "Set of cuda-enabled texture tools and compressors";
homepage = "https://github.com/castano/nvidia-texture-tools";
license = licenses.mit;
maintainers = with maintainers; [ wegank ];
platforms = platforms.unix;
};
}