1{ stdenv
2, lib
3, fetchFromGitHub
4, autoreconfHook
5, go-md2man
6, pkg-config
7, libcap
8, libseccomp
9, python3
10, systemd
11, yajl
12, nixosTests
13, criu
14}:
15
16let
17 # these tests require additional permissions
18 disabledTests = [
19 "test_capabilities.py"
20 "test_cwd.py"
21 "test_detach.py"
22 "test_exec.py"
23 "test_hooks.py"
24 "test_hostname.py"
25 "test_paths.py"
26 "test_pid.py"
27 "test_pid_file.py"
28 "test_preserve_fds.py"
29 "test_resources"
30 "test_seccomp"
31 "test_start.py"
32 "test_uid_gid.py"
33 "test_update.py"
34 "tests_libcrun_utils"
35 ];
36
37in
38stdenv.mkDerivation rec {
39 pname = "crun";
40 version = "1.3";
41
42 src = fetchFromGitHub {
43 owner = "containers";
44 repo = pname;
45 rev = version;
46 sha256 = "sha256-c0jXhqYdEpt4De1Z6VNwyrv0KJcf039Wp3ye0oTW0Qc=";
47 fetchSubmodules = true;
48 };
49
50 nativeBuildInputs = [ autoreconfHook go-md2man pkg-config python3 ];
51
52 buildInputs = [ libcap libseccomp systemd yajl ]
53 # Criu currently only builds on x86_64-linux
54 ++ lib.optional (lib.elem stdenv.hostPlatform.system criu.meta.platforms) criu;
55
56 enableParallelBuilding = true;
57
58 # we need this before autoreconfHook does its thing in order to initialize
59 # config.h with the correct values
60 postPatch = ''
61 echo ${version} > .tarball-version
62 echo '#define GIT_VERSION "${src.rev}"' > git-version.h
63
64 ${lib.concatMapStringsSep "\n" (e:
65 "substituteInPlace Makefile.am --replace 'tests/${e}' ''"
66 ) disabledTests}
67 '';
68
69 doCheck = true;
70
71 passthru.tests = { inherit (nixosTests) podman; };
72
73 meta = with lib; {
74 description = "A fast and lightweight fully featured OCI runtime and C library for running containers";
75 license = licenses.gpl2Plus;
76 platforms = platforms.linux;
77 inherit (src.meta) homepage;
78 maintainers = with maintainers; [ ] ++ teams.podman.members;
79 };
80}