summary refs log tree commit diff
path: root/pkgs/tools/graphics/nifskope/default.nix
blob: 0a053a3ad323d96a5ff7108f4bbf364ae1b596fa (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ lib, stdenv, fetchFromGitHub, qmake, qtbase, qttools, substituteAll, libGLU, wrapQtAppsHook, fetchpatch }:

stdenv.mkDerivation {
  pname = "nifskope";
  version = "2.0.dev7";

  src = fetchFromGitHub {
    owner = "niftools";
    repo = "nifskope";
    rev = "47b788d26ae0fa12e60e8e7a4f0fa945a510c7b2"; # `v${version}` doesn't work with submodules
    sha256 = "1wqpn53rkq28ws3apqghkzyrib4wis91x171ns64g8kp4q6mfczi";
    fetchSubmodules = true;
  };

  patches = [
    ./external-lib-paths.patch
    (substituteAll {
      src = ./qttools-bins.patch;
      qttools = "${qttools.dev}/bin";
    })
    (fetchpatch {
      name = "qt512-build-fix.patch";
      url = "https://github.com/niftools/nifskope/commit/30954e7f01f3d779a2a1fd37d363e8a6ad560bd3.patch";
      sha256 = "0d6xjj2mjjhdd7w1aig5f75jksjni16jyj0lxsz51pys6xqb6fpj";
    })
  ] ++ (lib.optional stdenv.isAarch64 ./no-sse-on-arm.patch);

  buildInputs = [ qtbase qttools libGLU.dev ];
  nativeBuildInputs = [ qmake wrapQtAppsHook ];

  preConfigure = ''
    shopt -s globstar
    for i in **/*.cpp; do
      substituteInPlace $i --replace /usr/share/nifskope $out/share/nifskope
    done
  '';

  enableParallelBuilding = true;

  # Inspired by install/linux-install/nifskope.spec.in.
  installPhase = ''
    runHook preInstall

    d=$out/share/nifskope
    mkdir -p $out/bin $out/share/applications $out/share/pixmaps $d/{shaders,lang}
    cp release/NifSkope $out/bin/
    cp ./res/nifskope.png $out/share/pixmaps/
    cp release/{nif.xml,kfm.xml,style.qss} $d/
    cp res/shaders/*.frag res/shaders/*.prog res/shaders/*.vert $d/shaders/
    cp ./res/lang/*.ts ./res/lang/*.tm $d/lang/
    cp ./install/linux-install/nifskope.desktop $out/share/applications

    substituteInPlace $out/share/applications/nifskope.desktop \
      --replace 'Exec=nifskope' "Exec=$out/bin/NifSkope" \
      --replace 'Icon=nifskope' "Icon=$out/share/pixmaps/nifskope.png"

    find $out/share -type f -exec chmod -x {} \;

    runHook postInstall
  '';

  meta = with lib; {
    homepage = "http://niftools.sourceforge.net/wiki/NifSkope";
    description = "A tool for analyzing and editing NetImmerse/Gamebryo '*.nif' files";
    maintainers = with maintainers; [ eelco ma27 ];
    platforms = platforms.linux;
    license = licenses.bsd3;
  };
}