forked from DGNum/liminix
build kernel only once for multiple outputs
e.g. vmlinux + zImage
This commit is contained in:
parent
e4ed9dbec9
commit
ff991508ae
4 changed files with 23 additions and 13 deletions
|
@ -4,6 +4,7 @@
|
||||||
kernel.config = {
|
kernel.config = {
|
||||||
OF = "y";
|
OF = "y";
|
||||||
};
|
};
|
||||||
|
kernel.makeTargets = ["arch/arm/boot/zImage"];
|
||||||
hardware.ram.startAddress = lim.parseInt "0x40000000";
|
hardware.ram.startAddress = lim.parseInt "0x40000000";
|
||||||
system.outputs.u-boot = pkgs.ubootQemuArm;
|
system.outputs.u-boot = pkgs.ubootQemuArm;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ let
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.networking) address interface;
|
inherit (pkgs.liminix.networking) address interface;
|
||||||
inherit (pkgs.liminix.services) bundle;
|
inherit (pkgs.liminix.services) bundle;
|
||||||
|
inherit (pkgs) liminix;
|
||||||
|
|
||||||
type_service = pkgs.liminix.lib.types.service;
|
type_service = pkgs.liminix.lib.types.service;
|
||||||
|
|
||||||
|
@ -41,11 +42,25 @@ in {
|
||||||
};
|
};
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
makeTargets = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
|
system.outputs =
|
||||||
|
let k = liminix.builders.kernel.override {
|
||||||
|
inherit (config.kernel) config src extraPatchPhase;
|
||||||
|
targets = config.kernel.makeTargets;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
kernel = k.vmlinux;
|
||||||
|
zimage = k.zImage;
|
||||||
|
};
|
||||||
|
|
||||||
kernel = rec {
|
kernel = rec {
|
||||||
modular = true; # disabling this is not yet supported
|
modular = true; # disabling this is not yet supported
|
||||||
|
makeTargets = ["vmlinux"];
|
||||||
config = {
|
config = {
|
||||||
IKCONFIG = "y";
|
IKCONFIG = "y";
|
||||||
IKCONFIG_PROC = "y";
|
IKCONFIG_PROC = "y";
|
||||||
|
|
|
@ -99,26 +99,18 @@ in
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
system.outputs = rec {
|
system.outputs = rec {
|
||||||
kernel = liminix.builders.kernel.override {
|
|
||||||
inherit (config.kernel) config src extraPatchPhase;
|
|
||||||
};
|
|
||||||
zimage = liminix.builders.kernel.override {
|
|
||||||
targets = ["arch/arm/boot/zImage"];
|
|
||||||
inherit (config.kernel) config src extraPatchPhase;
|
|
||||||
};
|
|
||||||
dtb = liminix.builders.dtb {
|
dtb = liminix.builders.dtb {
|
||||||
inherit (config.boot) commandLine;
|
inherit (config.boot) commandLine;
|
||||||
dts = config.hardware.dts.src;
|
dts = config.hardware.dts.src;
|
||||||
includes = config.hardware.dts.includes ++ [
|
includes = config.hardware.dts.includes ++ [
|
||||||
"${kernel.headers}/include"
|
"${o.kernel.headers}/include"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
uimage = liminix.builders.uimage {
|
uimage = liminix.builders.uimage {
|
||||||
commandLine = concatStringsSep " " config.boot.commandLine;
|
commandLine = concatStringsSep " " config.boot.commandLine;
|
||||||
inherit (config.hardware) loadAddress entryPoint;
|
inherit (config.hardware) loadAddress entryPoint;
|
||||||
inherit (config.boot) imageFormat;
|
inherit (config.boot) imageFormat;
|
||||||
inherit kernel;
|
inherit (o) kernel dtb;
|
||||||
inherit dtb;
|
|
||||||
};
|
};
|
||||||
rootdir =
|
rootdir =
|
||||||
let
|
let
|
||||||
|
|
|
@ -13,6 +13,7 @@ let
|
||||||
writeConfig = import ./write-kconfig.nix { inherit lib writeText; };
|
writeConfig = import ./write-kconfig.nix { inherit lib writeText; };
|
||||||
kconfigFile = writeConfig "kconfig" config;
|
kconfigFile = writeConfig "kconfig" config;
|
||||||
arch = stdenv.hostPlatform.linuxArch;
|
arch = stdenv.hostPlatform.linuxArch;
|
||||||
|
targetNames = map baseNameOf targets;
|
||||||
inherit lib; in
|
inherit lib; in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "kernel";
|
name = "kernel";
|
||||||
|
@ -35,7 +36,7 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
dontPatchELF = true;
|
dontPatchELF = true;
|
||||||
outputs = ["out" "headers" "modulesupport"];
|
outputs = ["out" "headers" "modulesupport"] ++ targetNames;
|
||||||
phases = [
|
phases = [
|
||||||
"unpackPhase"
|
"unpackPhase"
|
||||||
"butcherPkgconfig"
|
"butcherPkgconfig"
|
||||||
|
@ -92,12 +93,13 @@ stdenv.mkDerivation rec {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
make ${lib.concatStringsSep " " (map baseNameOf targets)} modules_prepare -j$NIX_BUILD_CORES
|
make ${lib.concatStringsSep " " targetNames} modules_prepare -j$NIX_BUILD_CORES
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${CROSS_COMPILE}strip -d vmlinux
|
${CROSS_COMPILE}strip -d vmlinux
|
||||||
cp ${lib.concatStringsSep " " targets} $out
|
${lib.concatStringsSep "\n" (map (f: "cp ${f} \$${baseNameOf f}") targets)}
|
||||||
|
cp vmlinux $out
|
||||||
mkdir -p $headers
|
mkdir -p $headers
|
||||||
cp -a include .config $headers/
|
cp -a include .config $headers/
|
||||||
mkdir -p $modulesupport
|
mkdir -p $modulesupport
|
||||||
|
|
Loading…
Reference in a new issue