forked from DGNum/liminix
43 lines
1.1 KiB
Nix
43 lines
1.1 KiB
Nix
|
{
|
||
|
lzma
|
||
|
, stdenv
|
||
|
, ubootTools
|
||
|
} :
|
||
|
let
|
||
|
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
|
||
|
in {
|
||
|
vmlinux
|
||
|
# , commandLine
|
||
|
# , fdt ? null
|
||
|
, entryPoint
|
||
|
# , extraName ? "" # e.g. socFamily
|
||
|
, loadAddress
|
||
|
} :
|
||
|
# patchDtbCommand = if (fdt != null) then ''
|
||
|
# ( cat vmlinux.stripped ${fdt} > vmlinux.tmp ) && mv vmlinux.tmp vmlinux.stripped
|
||
|
# '' else ''
|
||
|
# echo patch-cmdline vmlinux.stripped '${commandLine}'
|
||
|
# patch-cmdline vmlinux.stripped '${commandLine}'
|
||
|
# echo
|
||
|
# '';
|
||
|
stdenv.mkDerivation {
|
||
|
name = "kernel.image";
|
||
|
phases = [ "buildPhase" "installPhase" ];
|
||
|
nativeBuildInputs = [
|
||
|
# patchImage
|
||
|
lzma
|
||
|
stdenv.cc
|
||
|
ubootTools
|
||
|
];
|
||
|
buildPhase = ''
|
||
|
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S ${vmlinux} vmlinux.stripped
|
||
|
# {patchDtbCommand}
|
||
|
rm -f vmlinux.stripped.lzma
|
||
|
lzma -k -z vmlinux.stripped
|
||
|
mkimage -A mips -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n 'MIPS Liminix Linux ' -d vmlinux.stripped.lzma kernel.image
|
||
|
'';
|
||
|
installPhase = ''
|
||
|
cp kernel.image $out
|
||
|
'';
|
||
|
}
|