2019-06-07 22:46:33 +01:00
{ stdenv , fetchFromGitHub , bc , python , bison , flex , fuse , libarchive
, buildPackages } :
2017-01-16 21:24:21 +00:00
stdenv . mkDerivation rec {
2019-07-05 04:13:08 +01:00
pname = " l k l " ;
version = " 2 0 1 9 - 0 6 - 2 0 " ;
rev = " 0 a 4 e b e a d a d 1 2 b 9 4 d b 6 6 5 b 8 d a f 3 0 e 4 4 e 9 4 9 a 0 2 d 9 0 " ;
2017-01-16 21:24:21 +00:00
2017-05-23 23:43:22 +01:00
outputs = [ " d e v " " l i b " " o u t " ] ;
2018-10-14 21:36:17 +01:00
nativeBuildInputs = [ bc bison flex python ] ;
2017-05-23 00:41:22 +01:00
buildInputs = [ fuse libarchive ] ;
2017-01-16 21:24:21 +00:00
src = fetchFromGitHub {
inherit rev ;
2017-01-17 18:40:58 +00:00
owner = " l k l " ;
2017-01-16 21:24:21 +00:00
repo = " l i n u x " ;
2019-07-05 04:13:08 +01:00
sha256 = " 0 9 y 9 c i 3 j 0 l p 3 z 7 4 h 5 7 7 n g 2 s 9 a 4 n 4 g l q p q n d y c 9 i y 6 w d q a j 7 6 4 g m 6 " ;
2017-01-16 21:24:21 +00:00
} ;
2017-01-25 21:30:46 +00:00
# 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 " ;
2017-01-16 21:24:21 +00:00
installPhase = ''
2017-05-23 23:43:22 +01:00
mkdir - p $ out/bin $ lib/lib $ dev
2017-01-16 21:24:21 +00:00
cp tools/lkl/bin/lkl-hijack.sh $ out/bin
2017-05-23 23:43:22 +01:00
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 , "
2017-01-16 21:24:21 +00:00
2018-03-11 11:42:07 +00:00
cp tools/lkl / { cptofs , fs2tar , lklfuse } $ out/bin
ln - s cptofs $ out/bin/cpfromfs
2017-05-23 23:43:22 +01:00
cp - r tools/lkl/include $ dev /
2019-02-02 04:31:50 +00:00
cp tools/lkl/liblkl.a \
tools/lkl/lib/liblkl.so \
tools/lkl/lib/hijack/liblkl-hijack.so $ lib/lib
2017-01-16 21:24:21 +00:00
'' ;
# 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 " ] ;
2019-06-07 22:46:33 +01:00
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 } "
] ;
2017-01-16 21:24:21 +00:00
2017-05-20 14:38:01 +01:00
enableParallelBuilding = true ;
2017-01-16 21:24:21 +00:00
meta = with stdenv . lib ; {
2017-05-23 22:55:55 +01: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
'' ;
2017-05-21 14:25:55 +01:00
homepage = https://github.com/lkl/linux/ ;
2019-07-05 04:13:08 +01:00
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
2017-01-16 21:24:21 +00:00
license = licenses . gpl2 ;
maintainers = with maintainers ; [ copumpkin ] ;
} ;
}