depot/third_party/nixpkgs/pkgs/by-name/co/composefs/package.nix
Default email 2c76a4cb41 Project import generated by Copybara.
GitOrigin-RevId: c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad
2023-11-16 04:20:00 +00:00

100 lines
2.9 KiB
Nix

{ 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;
};
})