nixpkgs/pkgs/applications/virtualization/lkl/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

94 lines
3.3 KiB
Nix
Raw Normal View History

2021-07-27 14:52:47 +00:00
{ lib, stdenv, fetchFromGitHub, bc, python3, bison, flex, fuse, libarchive
, buildPackages
, firewallSupport ? false
}:
2017-01-16 21:24:21 +00:00
stdenv.mkDerivation rec {
pname = "lkl";
# NOTE: pinned to the last known version that doesn't have a hang in cptofs.
# Please verify `nix build -f nixos/release-combined.nix nixos.ova` works
# before attempting to update again.
# ref: https://github.com/NixOS/nixpkgs/pull/219434
2023-03-03 23:38:17 +00:00
version = "2022-08-08";
2017-01-16 21:24:21 +00:00
outputs = [ "dev" "lib" "out" ];
2017-01-16 21:24:21 +00:00
src = fetchFromGitHub {
2017-01-17 18:40:58 +00:00
owner = "lkl";
2017-01-16 21:24:21 +00:00
repo = "linux";
2023-03-03 23:38:17 +00:00
rev = "ffbb4aa67b3e0a64f6963f59385a200d08cb2d8b";
sha256 = "sha256-24sNREdnhkF+P+3P0qEh2tF1jHKF7KcbFSn/rPK2zWs=";
2017-01-16 21:24:21 +00:00
};
nativeBuildInputs = [ bc bison flex python3 ];
buildInputs = [ fuse libarchive ];
postPatch = ''
# Fix a /usr/bin/env reference in here that breaks sandboxed builds
patchShebangs arch/lkl/scripts
patchShebangs scripts/ld-version.sh
# Fixup build with newer Linux headers: https://github.com/lkl/linux/pull/484
sed '1i#include <linux/sockios.h>' -i tools/lkl/lib/hijack/xlate.c
2023-05-19 13:44:05 +00:00
'' + lib.optionalString stdenv.isi686 ''
echo CONFIG_KALLSYMS=n >> arch/lkl/configs/defconfig
echo CONFIG_KALLSYMS_BASE_RELATIVE=n >> arch/lkl/configs/defconfig
'' + lib.optionalString firewallSupport ''
cat ${./lkl-defconfig-enable-nftables} >> arch/lkl/configs/defconfig
'';
2017-01-16 21:24:21 +00:00
installPhase = ''
mkdir -p $out/bin $lib/lib $dev
2017-01-16 21:24:21 +00:00
cp tools/lkl/bin/lkl-hijack.sh $out/bin
sed -i $out/bin/lkl-hijack.sh \
-e "s,LD_LIBRARY_PATH=.*,LD_LIBRARY_PATH=$lib/lib,"
2017-01-16 21:24:21 +00:00
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
2017-01-16 21:24:21 +00:00
'';
postFixup = ''
ln -s $out/bin/lklfuse $out/bin/mount.fuse.lklfuse
'';
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 = [ "format" "fortify" ];
# Fixes the following error when using liblkl-hijack.so on aarch64-linux:
# symbol lookup error: liblkl-hijack.so: undefined symbol: __aarch64_ldadd4_sync
env.NIX_CFLAGS_LINK = "-lgcc_s";
2019-06-07 21:46:33 +00:00
makeFlags = [
"-C tools/lkl"
"CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
2017-01-16 21:24:21 +00:00
enableParallelBuilding = true;
2017-01-16 21:24:21 +00:00
meta = with lib; {
description = "Linux kernel as a library";
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 = "https://github.com/lkl/linux/";
platforms = platforms.linux; # 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 raitobezarius ];
2017-01-16 21:24:21 +00:00
};
}