summary refs log tree commit diff
path: root/pkgs/applications/virtualization/lkl/default.nix
blob: b1b3c3aebeefbb4fc0f8960d93ebad07468fbadf (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
{ stdenv, fetchFromGitHub, bc, python, fuse, libarchive }:

stdenv.mkDerivation rec {
  name = "lkl-${stdenv.lib.substring 0 7 rev}";
  rev  = "d74707304d4e4614081ae2a612a833aeb46622b5";

  buildInputs = [ bc python fuse libarchive ];

  src = fetchFromGitHub {
    inherit rev;
    owner  = "lkl";
    repo   = "linux";
    sha256 = "0x1hdjsrj6hfk1sgfw11ihm00fmp6g158sr2q3cgjy2b6jnsr4hp";
  };

  installPhase = ''
    mkdir -p $out/{bin,lib}

    # This tool assumes a different directory structure so let's point it at the right location
    cp tools/lkl/bin/lkl-hijack.sh $out/bin
    substituteInPlace $out/bin/lkl-hijack.sh --replace '/../' '/../lib'

    cp tools/lkl/{cptofs,cpfromfs,fs2tar,lklfuse} $out/bin
    cp -r tools/lkl/include $out
    cp tools/lkl/liblkl*.{a,so} $out/lib
  '';

  # We turn off format and fortify because of these errors (fortify implies -O2, which breaks the jitter entropy code):
  #   fs/xfs/xfs_log_recover.c:2575:3: error: format not a string literal and no format arguments [-Werror=format-security]
  #   crypto/jitterentropy.c:54:3: error: #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
  hardeningDisable = [ "format" "fortify" ];

  makeFlags = "-C tools/lkl";

  enableParallelBuilds = true;

  meta = with stdenv.lib; {
    description = "LKL (Linux Kernel Library) aims to allow reusing the Linux kernel code as extensively as possible with minimal effort and reduced maintenance overhead";
    platforms   = platforms.linux; # Darwin probably works too but I haven't tested it
    license     = licenses.gpl2;
    maintainers = with maintainers; [ copumpkin ];
  };
}