1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 qmake,
6 qtbase,
7 qttools,
8 replaceVars,
9 libGLU,
10 zlib,
11 wrapQtAppsHook,
12 fetchpatch,
13}:
14
15stdenv.mkDerivation {
16 pname = "nifskope";
17 version = "2.0.dev7";
18
19 src = fetchFromGitHub {
20 owner = "niftools";
21 repo = "nifskope";
22 rev = "47b788d26ae0fa12e60e8e7a4f0fa945a510c7b2"; # `v${version}` doesn't work with submodules
23 hash = "sha256-8TNXDSZ3okeMtuGEHpKOnKyY/Z/w4auG5kjgmUexF/M=";
24 fetchSubmodules = true;
25 };
26
27 patches = [
28 ./external-lib-paths.patch
29 ./zlib.patch
30 (replaceVars ./qttools-bins.patch {
31 qttools = "${qttools.dev}/bin";
32 })
33 (fetchpatch {
34 name = "qt512-build-fix.patch";
35 url = "https://github.com/niftools/nifskope/commit/30954e7f01f3d779a2a1fd37d363e8a6ad560bd3.patch";
36 sha256 = "0d6xjj2mjjhdd7w1aig5f75jksjni16jyj0lxsz51pys6xqb6fpj";
37 })
38 ]
39 ++ (lib.optional stdenv.hostPlatform.isAarch64 ./no-sse-on-arm.patch);
40
41 buildInputs = [
42 qtbase
43 qttools
44 libGLU
45 zlib
46 ];
47 nativeBuildInputs = [
48 qmake
49 wrapQtAppsHook
50 ];
51
52 preConfigure = ''
53 shopt -s globstar
54 for i in **/*.cpp; do
55 substituteInPlace $i --replace /usr/share/nifskope $out/share/nifskope
56 done
57 '';
58
59 # Inspired by install/linux-install/nifskope.spec.in.
60 installPhase = ''
61 runHook preInstall
62
63 d=$out/share/nifskope
64 mkdir -p $out/bin $out/share/applications $out/share/pixmaps $d/{shaders,lang}
65 cp release/NifSkope $out/bin/
66 cp ./res/nifskope.png $out/share/pixmaps/
67 cp release/{nif.xml,kfm.xml,style.qss} $d/
68 cp res/shaders/*.frag res/shaders/*.prog res/shaders/*.vert $d/shaders/
69 cp ./res/lang/*.ts ./res/lang/*.tm $d/lang/
70 cp ./install/linux-install/nifskope.desktop $out/share/applications
71
72 substituteInPlace $out/share/applications/nifskope.desktop \
73 --replace 'Exec=nifskope' "Exec=$out/bin/NifSkope" \
74 --replace 'Icon=nifskope' "Icon=$out/share/pixmaps/nifskope.png"
75
76 find $out/share -type f -exec chmod -x {} \;
77
78 runHook postInstall
79 '';
80
81 meta = with lib; {
82 homepage = "https://github.com/niftools/nifskope";
83 description = "Tool for analyzing and editing NetImmerse/Gamebryo '*.nif' files";
84 maintainers = [ ];
85 platforms = platforms.linux;
86 license = licenses.bsd3;
87 mainProgram = "NifSkope";
88 };
89}