You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

default.nix 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. { stdenv, fetchFromGitHub, bc, python, bison, flex, fuse, libarchive
  2. , buildPackages }:
  3. stdenv.mkDerivation rec {
  4. pname = "lkl";
  5. version = "2019-10-04";
  6. rev = "06ca3ddb74dc5b84fa54fa1746737f2df502e047";
  7. outputs = [ "dev" "lib" "out" ];
  8. nativeBuildInputs = [ bc bison flex python ];
  9. buildInputs = [ fuse libarchive ];
  10. src = fetchFromGitHub {
  11. inherit rev;
  12. owner = "lkl";
  13. repo = "linux";
  14. sha256 = "0qjp0r338bwgrqdsvy5mkdh7ryas23m47yvxfwdknfyl0k3ylq62";
  15. };
  16. # Fix a /usr/bin/env reference in here that breaks sandboxed builds
  17. prePatch = "patchShebangs arch/lkl/scripts";
  18. installPhase = ''
  19. mkdir -p $out/bin $lib/lib $dev
  20. cp tools/lkl/bin/lkl-hijack.sh $out/bin
  21. sed -i $out/bin/lkl-hijack.sh \
  22. -e "s,LD_LIBRARY_PATH=.*,LD_LIBRARY_PATH=$lib/lib,"
  23. cp tools/lkl/{cptofs,fs2tar,lklfuse} $out/bin
  24. ln -s cptofs $out/bin/cpfromfs
  25. cp -r tools/lkl/include $dev/
  26. cp tools/lkl/liblkl.a \
  27. tools/lkl/lib/liblkl.so \
  28. tools/lkl/lib/hijack/liblkl-hijack.so $lib/lib
  29. '';
  30. # We turn off format and fortify because of these errors (fortify implies -O2, which breaks the jitter entropy code):
  31. # fs/xfs/xfs_log_recover.c:2575:3: error: format not a string literal and no format arguments [-Werror=format-security]
  32. # 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."
  33. hardeningDisable = [ "format" "fortify" ];
  34. makeFlags = [
  35. "-C tools/lkl"
  36. "CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
  37. "HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
  38. "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
  39. ];
  40. enableParallelBuilding = true;
  41. meta = with stdenv.lib; {
  42. description = "The Linux kernel as a library";
  43. longDescription = ''
  44. LKL (Linux Kernel Library) aims to allow reusing the Linux kernel code as
  45. extensively as possible with minimal effort and reduced maintenance
  46. overhead
  47. '';
  48. homepage = https://github.com/lkl/linux/;
  49. platforms = [ "x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux" ]; # Darwin probably works too but I haven't tested it
  50. license = licenses.gpl2;
  51. maintainers = with maintainers; [ copumpkin ];
  52. };
  53. }