summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/co/composefs/package.nix
blob: 27f7a590d1123062a45264a7c513012ba78c0805 (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
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch,
  meson,
  ninja,
  go-md2man,
  pkg-config,
  openssl,
  fuse3,
  libcap,
  python3,
  which,
  valgrind,
  erofs-utils,
  fsverity-utils,
  nix-update-script,
  testers,
  nixosTests,

  fuseSupport ? lib.meta.availableOn stdenv.hostPlatform fuse3,
  enableValgrindCheck ? false,
  installExperimentalTools ? false,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "composefs";
  version = "1.0.8";

  src = fetchFromGitHub {
    owner = "composefs";
    repo = "composefs";
    tag = "v${finalAttrs.version}";
    hash = "sha256-nuQ3R/0eDS58HmN+0iXcYT5EtkY3J257EdtLir5vm4c=";
  };

  strictDeps = true;
  outputs = [
    "out"
    "lib"
    "dev"
  ];

  patches = [
    # "tests: ignore EOPNOTSUPP in in fsverity tests" https://github.com/composefs/composefs/pull/415
    (fetchpatch {
      url = "https://github.com/composefs/composefs/commit/b3cb176a771386081c993e29ae42e77dabe5a577.patch";
      hash = "sha256-nzUENLM24G6NezhPywVsRzRgWmL1VZdMfZTsXNorJl8=";
    })
  ];

  postPatch =
    # 'both_libraries' as an install target always builds both versions.
    #  This results in double disk usage for normal builds and broken static builds,
    #  so we replace it with the regular library target.
    ''
      substituteInPlace libcomposefs/meson.build \
        --replace-fail "both_libraries" "library"
    ''
    + lib.optionalString installExperimentalTools ''
      substituteInPlace tools/meson.build \
        --replace-fail "install : false" "install : true"
    '';

  nativeBuildInputs = [
    meson
    ninja
    go-md2man
    pkg-config
  ];
  buildInputs = [
    openssl
  ]
  ++ lib.optional fuseSupport fuse3
  ++ lib.filter (lib.meta.availableOn stdenv.hostPlatform) [
    libcap
  ];

  doCheck = true;
  nativeCheckInputs = [
    python3
    which
  ]
  ++ lib.optional enableValgrindCheck valgrind
  ++ lib.optional fuseSupport fuse3
  ++ lib.filter (lib.meta.availableOn stdenv.buildPlatform) [
    erofs-utils
    fsverity-utils
  ];

  mesonCheckFlags = lib.optionals enableValgrindCheck [ "--setup=valgrind" ];

  preCheck = ''
    patchShebangs --build ../tests/*dir ../tests/*.sh
  '';

  passthru = {
    updateScript = nix-update-script { };
    tests = {
      # Broken on aarch64 unrelated to this package: https://github.com/NixOS/nixpkgs/issues/291398
      inherit (nixosTests) activation-etc-overlay-immutable activation-etc-overlay-mutable;
      pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
    };
  };

  meta = {
    description = "File system for mounting container images";
    homepage = "https://github.com/composefs/composefs";
    changelog = "https://github.com/composefs/composefs/releases/tag/v${finalAttrs.version}";
    license = with lib.licenses; [
      gpl2Only
      asl20
    ];
    maintainers = with lib.maintainers; [ kiskae ];
    mainProgram = "mkcomposefs";
    pkgConfigModules = [ "composefs" ];
    platforms = lib.platforms.unix;
    badPlatforms = lib.platforms.darwin;
  };
})