about summary refs log tree commit diff
path: root/pkgs/by-name/nv/nvidia-texture-tools/package.nix
blob: 3f2bd5ad36a3557724b64e92725cfdbcaf71a948 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ 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.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;
  };
}