about summary refs log tree commit diff
path: root/pkgs/tools/filesystems/dwarfs/default.nix
blob: 719ccd1e23d2198439145af26871e7a07783ccd1 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{
  lib,
  fetchFromGitHub,
  stdenv,
  substituteAll,
  bison,
  boost,
  cmake,
  double-conversion,
  fmt,
  fuse3,
  flac,
  glog,
  gtest,
  howard-hinnant-date,
  jemalloc,
  libarchive,
  libevent,
  libunwind,
  lz4,
  openssl,
  pkg-config,
  python3,
  range-v3,
  ronn,
  xxHash,
  utf8cpp,
  zstd,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "dwarfs";
  version = "0.9.10";
  src = fetchFromGitHub {
    owner = "mhx";
    repo = "dwarfs";
    rev = "refs/tags/v${finalAttrs.version}";
    fetchSubmodules = true;
    hash = "sha256-uyYNs+fDV5BfQwfX9Wi3BwiKjSDQHAKRJ1+UvS/fHoE=";
  };

  cmakeFlags = [
    "-DNIXPKGS_DWARFS_VERSION_OVERRIDE=v${finalAttrs.version}" # see https://github.com/mhx/dwarfs/issues/155

    # Needs to be set so `dwarfs` does not try to download `gtest`; it is not
    # a submodule, see: https://github.com/mhx/dwarfs/issues/188#issuecomment-1907657083
    "-DPREFER_SYSTEM_GTEST=ON"

    # These should no longer be necessary with a version > 0.9.10:
    # * https://github.com/mhx/dwarfs/commit/593b22a8a90eb66c0898ae06f097f32f4bf3dfd4
    # * https://github.com/mhx/dwarfs/commit/6e9608b2b01be13e41e6b728aae537c14c00ad82
    # * https://github.com/mhx/dwarfs/commit/ce4bee1ad63c666da57d2cdae9fd65214d8dab7f
    "-DPREFER_SYSTEM_LIBFMT=ON"
    "-DPREFER_SYSTEM_ZSTD=ON"
    "-DPREFER_SYSTEM_XXHASH=ON"

    # may be added under an option in the future
    # "-DWITH_LEGACY_FUSE=ON"

    "-DWITH_TESTS=ON"
  ];

  nativeBuildInputs = [
    bison
    cmake
    howard-hinnant-date # uses only the header-only parts
    pkg-config
    range-v3 # header-only library
    ronn
    (python3.withPackages (ps: [ ps.mistletoe ])) # for man pages
  ];

  buildInputs = [
    # dwarfs
    boost
    flac # optional; allows automatic audio compression
    fmt
    fuse3
    jemalloc
    libarchive
    lz4
    xxHash
    utf8cpp
    zstd

    # folly
    double-conversion
    glog
    libevent
    libunwind
    openssl
  ];

  doCheck = true;
  nativeCheckInputs = [
    # https://github.com/mhx/dwarfs/issues/188#issuecomment-1907574427
    # `dwarfs` sets C++20 as the minimum, see
    #     https://github.com/mhx/dwarfs/blob/2cb5542a5d4274225c5933370adcf00035f6c974/CMakeLists.txt#L129
    # Thus the `gtest` headers, when included,
    # refer to symbols that only exist in `.so` files compiled with that version.
    (gtest.override { cxx_standard = "20"; })
  ];
  # these fail inside of the sandbox due to missing access
  # to the FUSE device
  GTEST_FILTER =
    let
      disabledTests = [
        "dwarfs/tools_test.end_to_end/*"
        "dwarfs/tools_test.mutating_and_error_ops/*"
        "dwarfs/tools_test.categorize/*"
      ];
    in
      "-${lib.concatStringsSep ":" disabledTests}";

  meta = {
    description = "Fast high compression read-only file system";
    homepage = "https://github.com/mhx/dwarfs";
    changelog = "https://github.com/mhx/dwarfs/blob/v${finalAttrs.version}/CHANGES.md";
    license = lib.licenses.gpl3Plus;
    maintainers = [ lib.maintainers.luftmensch-luftmensch ];
    platforms = lib.platforms.linux;
  };
})