about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/co/composefs/package.nix
blob: 9b5d37dc164586789545411d02d25ef584361a60 (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
{ lib
, stdenv
, fetchFromGitHub

, autoreconfHook
, pandoc
, pkg-config
, openssl
, fuse3
, yajl
, libcap
, libseccomp
, python3
, which
, valgrind
, erofs-utils
, fsverity-utils
, nix-update-script
, testers

, fuseSupport ? lib.meta.availableOn stdenv.hostPlatform fuse3
, yajlSupport ? lib.meta.availableOn stdenv.hostPlatform yajl
, enableValgrindCheck ? false
, installExperimentalTools ? false
}:
# https://github.com/containers/composefs/issues/204
assert installExperimentalTools -> (!stdenv.hostPlatform.isMusl);
stdenv.mkDerivation (finalAttrs: {
  pname = "composefs";
  version = "1.0.1";

  src = fetchFromGitHub {
    owner = "containers";
    repo = "composefs";
    rev = "v${finalAttrs.version}";
    hash = "sha256-8YbDKw4jYEU6l3Nmqu3gsT9VX0lwYF/39hhcwzgTynY=";
  };

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

  postPatch = lib.optionalString installExperimentalTools ''
    sed -i "s/noinst_PROGRAMS +\?=/bin_PROGRAMS +=/g" tools/Makefile.am
  '';

  configureFlags = lib.optionals enableValgrindCheck [
    (lib.enableFeature true "valgrind-test")
  ];

  nativeBuildInputs = [ autoreconfHook pandoc pkg-config ];
  buildInputs = [ openssl ]
    ++ lib.optional fuseSupport fuse3
    ++ lib.optional yajlSupport yajl
    ++ lib.filter (lib.meta.availableOn stdenv.hostPlatform) (
    [
      libcap
      libseccomp
    ]
  );

  # yajl is required to read the test json files
  doCheck = true;
  nativeCheckInputs = [ python3 which ]
    ++ lib.optional enableValgrindCheck valgrind
    ++ lib.optional fuseSupport fuse3
    ++ lib.filter (lib.meta.availableOn stdenv.buildPlatform) [ erofs-utils fsverity-utils ];

  preCheck = ''
    patchShebangs --build tests/*dir tests/*.sh
    substituteInPlace tests/*.sh \
      --replace " /tmp" " $TMPDIR" \
      --replace " /var/tmp" " $TMPDIR"
  '' + lib.optionalString (stdenv.hostPlatform.isMusl || !yajlSupport) ''
    # test relies on `composefs-from-json` tool
    # MUSL: https://github.com/containers/composefs/issues/204
    substituteInPlace tests/Makefile \
      --replace " check-checksums" ""
  '' + lib.optionalString enableValgrindCheck ''
    # valgrind is incompatible with seccomp
    substituteInPlace tests/test-checksums.sh \
      --replace "composefs-from-json" "composefs-from-json --no-sandbox"
  '';

  passthru = {
    updateScript = nix-update-script { };
    tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
  };

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