lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, help2man
6, lz4
7, lzo
8, nixosTests
9, which
10, xz
11, zlib
12, zstd
13}:
14
15stdenv.mkDerivation rec {
16 pname = "squashfs";
17 version = "4.5.1";
18
19 src = fetchFromGitHub {
20 owner = "plougher";
21 repo = "squashfs-tools";
22 rev = version;
23 sha256 = "sha256-Y3ZPjeE9HN1F+NtGe6EchYziWrTPVQ4SuKaCvNbXMKI=";
24 };
25
26 patches = [
27 # remove once https://github.com/plougher/squashfs-tools/pull/177 is merged and in a release
28 (fetchpatch {
29 url = "https://github.com/plougher/squashfs-tools/commit/6100e82c7e7f18f503c003c67c87791025d5f01b.patch";
30 sha256 = "sha256-bMBQsbSKQ4E7r9avns2QaomGAYl3s82m58gYyTQdB08=";
31 })
32 # This patch adds an option to pad filesystems (increasing size) in
33 # exchange for better chunking / binary diff calculation.
34 ./4k-align.patch
35 ] ++ lib.optional stdenv.isDarwin ./darwin.patch;
36
37 strictDeps = true;
38 nativeBuildInputs = [ which ]
39 # when cross-compiling help2man cannot run the cross-compiled binary
40 ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ help2man ];
41 buildInputs = [ zlib xz zstd lz4 lzo ];
42
43 preBuild = ''
44 cd squashfs-tools
45 '' ;
46
47 installFlags = [
48 "INSTALL_DIR=${placeholder "out"}/bin"
49 "INSTALL_MANPAGES_DIR=${placeholder "out"}/share/man/man1"
50 ];
51
52 makeFlags = [
53 "XZ_SUPPORT=1"
54 "ZSTD_SUPPORT=1"
55 "LZ4_SUPPORT=1"
56 "LZO_SUPPORT=1"
57 ];
58
59 passthru.tests = {
60 nixos-iso-boots-and-verifies = nixosTests.boot.biosCdrom;
61 };
62
63 meta = with lib; {
64 homepage = "https://github.com/plougher/squashfs-tools";
65 description = "Tool for creating and unpacking squashfs filesystems";
66 platforms = platforms.unix;
67 license = licenses.gpl2Plus;
68 maintainers = with maintainers; [ ruuda ];
69 mainProgram = "mksquashfs";
70 };
71}