aboutsummaryrefslogtreecommitdiff
path: root/srcds-pkgs/vtf-thumbnailer/default.nix
blob: 4fef9c1004ab1f461b3e1328fee927e7a5040999 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{ lib, stdenv, fetchFromGitHub, fetchgit
, cmake, pkg-config, makeWrapper
, bzip2, xz, zstd, zlib-ng
, openssl, cryptopp
}:
stdenv.mkDerivation (self: {
  pname = "vtf-thumbnailer";
  version = "0.2.0";

  src = fetchFromGitHub {
    owner = "craftablescience";
    repo = self.pname;
    tag = "v${self.version}";
    fetchSubmodules = true;
    hash = "sha256-cK8S9ozZXCzo8WWWazafyiPi+7YHWd950xODPd9x/aE=";
  };

  cryptopp-src = fetchgit {
    url = "https://github.com/weidai11/cryptopp";
    tag = "CRYPTOPP_8_9_0";
    hash = "sha256-HV+afSFkiXdy840JbHBTR8lLL0GMwsN3QdwaoQmicpQ=";
  };

  zlib-src = fetchgit {
    url = "https://github.com/zlib-ng/zlib-ng";
    tag = "2.2.5";
    hash = "sha256-VB4aegnZCZut9H/Hu2PBwwldpbM7E67D5QFYCKgq3mg=";
  };

  bzip2-src = fetchgit {
    url = "https://gitlab.com/bzip2/bzip2";
    rev = "66c46b8c9436613fd81bc5d03f63a61933a4dcc3";
    hash = "sha256-JuwmLBwtUPW9Wt31wIX5NMCu0VTxt16XaBQ2c5rFTY4=";
  };

  xz-src = fetchgit {
    url = "https://github.com/tukaani-project/xz";
    tag = "v5.8.1";
    hash = "sha256-29w1K3zC58oFkBvSdwpKu694S+42FxzqOtWBpS7iJ+A=";
  };

  zstd-src = fetchgit {
    url = "https://github.com/facebook/zstd";
    tag = "v1.5.7";
    hash = "sha256-tNFWIT9ydfozB8dWcmTMuZLCQmQudTFJIkSr0aG7S44=";
  };

  nativeBuildInputs = [
    cmake
    makeWrapper
  ];

  buildInputs = [
    bzip2
    cryptopp
    openssl
    pkg-config
    xz
    zlib-ng
    zstd
  ];

  patches = [
    ./fix-miniz-cmake-dirs.patch
    ./fix-cmake-outputs.patch
  ];
  cmakeFlags = with self; [
    (lib.cmakeFeature "CRYPTOPP_SOURCES" "${cryptopp-src}")
    (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ZLIB" "${zlib-src}")
    (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_BZIP2" "/build/bzip2tmp")
    (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBLZMA" "${xz-src}")
    (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ZSTD" "${zstd-src}")
    (lib.cmakeBool "MZ_OPENSSL" true)
    (lib.cmakeBool "MARETF_BUILD_INSTALLER" true)
    (lib.cmakeFeature "CPACK_GENERATOR" "DEB")
  ];

  postUnpack = ''
    cp -r ${self.bzip2-src} /build/bzip2tmp
    chmod -R +w /build/bzip2tmp
  '';

  LANG = "C.UTF-8";

  meta = {
    description = "Adds previews for VTF files in your file explorer of choice on Windows and Linux";
    homepage = "https://github.com/craftablescience/vtf-thumbnailer";
    license = lib.licenses.mit;
    platforms = [ "x86_64-linux" ];
    changelog = "https://github.com/craftablescience/vtf-thumbnailer/releases/tag/v${self.version}";
  };
})