1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 meson,
6 ninja,
7 go-md2man,
8 pkg-config,
9 openssl,
10 fuse3,
11 libcap,
12 python3,
13 which,
14 valgrind,
15 erofs-utils,
16 fsverity-utils,
17 nix-update-script,
18 testers,
19 nixosTests,
20
21 fuseSupport ? lib.meta.availableOn stdenv.hostPlatform fuse3,
22 enableValgrindCheck ? false,
23 installExperimentalTools ? false,
24}:
25stdenv.mkDerivation (finalAttrs: {
26 pname = "composefs";
27 version = "1.0.8";
28
29 src = fetchFromGitHub {
30 owner = "containers";
31 repo = "composefs";
32 tag = "v${finalAttrs.version}";
33 hash = "sha256-nuQ3R/0eDS58HmN+0iXcYT5EtkY3J257EdtLir5vm4c=";
34 };
35
36 strictDeps = true;
37 outputs = [
38 "out"
39 "lib"
40 "dev"
41 ];
42
43 postPatch =
44 # 'both_libraries' as an install target always builds both versions.
45 # This results in double disk usage for normal builds and broken static builds,
46 # so we replace it with the regular library target.
47 ''
48 substituteInPlace libcomposefs/meson.build \
49 --replace-fail "both_libraries" "library"
50 ''
51 + lib.optionalString installExperimentalTools ''
52 substituteInPlace tools/meson.build \
53 --replace-fail "install : false" "install : true"
54 '';
55
56 nativeBuildInputs = [
57 meson
58 ninja
59 go-md2man
60 pkg-config
61 ];
62 buildInputs = [
63 openssl
64 ]
65 ++ lib.optional fuseSupport fuse3
66 ++ lib.filter (lib.meta.availableOn stdenv.hostPlatform) ([
67 libcap
68 ]);
69
70 doCheck = true;
71 nativeCheckInputs = [
72 python3
73 which
74 ]
75 ++ lib.optional enableValgrindCheck valgrind
76 ++ lib.optional fuseSupport fuse3
77 ++ lib.filter (lib.meta.availableOn stdenv.buildPlatform) [
78 erofs-utils
79 fsverity-utils
80 ];
81
82 mesonCheckFlags = lib.optionals enableValgrindCheck "--setup=valgrind";
83
84 preCheck = ''
85 patchShebangs --build ../tests/*dir ../tests/*.sh
86 '';
87
88 passthru = {
89 updateScript = nix-update-script { };
90 tests = {
91 # Broken on aarch64 unrelated to this package: https://github.com/NixOS/nixpkgs/issues/291398
92 inherit (nixosTests) activation-etc-overlay-immutable activation-etc-overlay-mutable;
93 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
94 };
95 };
96
97 meta = {
98 description = "File system for mounting container images";
99 homepage = "https://github.com/containers/composefs";
100 changelog = "https://github.com/containers/composefs/releases/tag/v${finalAttrs.version}";
101 license = with lib.licenses; [
102 gpl2Only
103 asl20
104 ];
105 maintainers = with lib.maintainers; [ kiskae ];
106 mainProgram = "mkcomposefs";
107 pkgConfigModules = [ "composefs" ];
108 platforms = lib.platforms.unix;
109 badPlatforms = lib.platforms.darwin;
110 };
111})