2021-08-05 21:33:18 +00:00
{ lib , stdenv , fetchFromGitHub , bc , python3 , bison , flex , fuse , libarchive
2020-04-24 23:36:52 +00:00
, buildPackages } :
stdenv . mkDerivation rec {
pname = " l k l " ;
version = " 2 0 1 9 - 1 0 - 0 4 " ;
rev = " 0 6 c a 3 d d b 7 4 d c 5 b 8 4 f a 5 4 f a 1 7 4 6 7 3 7 f 2 d f 5 0 2 e 0 4 7 " ;
outputs = [ " d e v " " l i b " " o u t " ] ;
2021-08-05 21:33:18 +00:00
nativeBuildInputs = [ bc bison flex python3 ] ;
2020-04-24 23:36:52 +00:00
buildInputs = [ fuse libarchive ] ;
src = fetchFromGitHub {
inherit rev ;
owner = " l k l " ;
repo = " l i n u x " ;
sha256 = " 0 q j p 0 r 3 3 8 b w g r q d s v y 5 m k d h 7 r y a s 2 3 m 4 7 y v x f w d k n f y l 0 k 3 y l q 6 2 " ;
} ;
# Fix a /usr/bin/env reference in here that breaks sandboxed builds
prePatch = " p a t c h S h e b a n g s a r c h / l k l / s c r i p t s " ;
# Fixup build with newer Linux headers: https://github.com/lkl/linux/pull/484
postPatch = " s e d ' 1 i # i n c l u d e < l i n u x / s o c k i o s . h > ' - i t o o l s / l k l / l i b / h i j a c k / x l a t e . c " ;
installPhase = ''
mkdir - p $ out/bin $ lib/lib $ dev
cp tools/lkl/bin/lkl-hijack.sh $ out/bin
sed - i $ out/bin/lkl-hijack.sh \
- e " s , L D _ L I B R A R Y _ P A T H = . * , L D _ L I B R A R Y _ P A T H = $ l i b / l i b , "
cp tools/lkl / { cptofs , fs2tar , lklfuse } $ out/bin
ln - s cptofs $ out/bin/cpfromfs
cp - r tools/lkl/include $ dev /
cp tools/lkl/liblkl.a \
tools/lkl/lib/liblkl.so \
tools/lkl/lib/hijack/liblkl-hijack.so $ lib/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 = [ " f o r m a t " " f o r t i f y " ] ;
makeFlags = [
" - C t o o l s / l k l "
" C C = ${ stdenv . cc } / b i n / ${ stdenv . cc . targetPrefix } c c "
" H O S T C C = ${ buildPackages . stdenv . cc } / b i n / ${ buildPackages . stdenv . cc . targetPrefix } c c "
" C R O S S _ C O M P I L E = ${ stdenv . cc . targetPrefix } "
] ;
enableParallelBuilding = true ;
2021-01-15 22:18:51 +00:00
meta = with lib ; {
2020-04-24 23:36:52 +00:00
description = " T h e L i n u x k e r n e l a s a l i b r a r y " ;
longDescription = ''
LKL ( Linux Kernel Library ) aims to allow reusing the Linux kernel code as
extensively as possible with minimal effort and reduced maintenance
overhead
'' ;
homepage = " h t t p s : / / g i t h u b . c o m / l k l / l i n u x / " ;
platforms = [ " x 8 6 _ 6 4 - l i n u x " " a a r c h 6 4 - l i n u x " " a r m v 7 l - l i n u x " " a r m v 6 l - l i n u x " ] ; # Darwin probably works too but I haven't tested it
license = licenses . gpl2 ;
maintainers = with maintainers ; [ copumpkin ] ;
} ;
}