src/userspace: merge back into initramfs

Previously ownerboot had separate `userspace` (the initramfs
contents without kernel modules) and `initramfs` (the complete
initramfs) expressions.  This was done in order to allow the use of
CONFIG_INITRAMFS_SOURCE, which links an initramfs image into the
kernel itself.

I did this because I was having a hard time getting coreboot to load
a separate initrd on rk3399.  I have since solved that problem, and
am now using coreboot to load an initramfs on all platforms.  There
is no longer any need for this unusual separation.
master
Adam Joseph
parent f26abaaeba
commit 98c5638e64

@ -10,8 +10,7 @@ Ownerboot creates a second mutually-recursive package set containing all of the
* `coreboot` -- a Nix package for coreboot, since it is not in nixpkgs
* `kernel` -- the Linux kernel, using a custom (non-nixpkgs) expression
* `userspace` -- the userspace for the linux initramfs
* `initramfs` -- merges `userspace` with the boot-critical modules from `kernel` and wraps it in a properly-formatted `cpio` archive
* `initramfs` -- the initramfs
* `arm-trusted-firmware` -- the ARM EL3 privileged routines
* `fit` -- generates a FIT payload
* `iasl` -- the Intel ACPI compiler

@ -29,7 +29,6 @@ let
coreboot = final.callPackage ./coreboot { };
image = final.callPackage ./image { };
kernel = final.callPackage ./kernel { };
userspace = final.callPackage ./userspace { };
initramfs = final.callPackage ./initramfs { };
flashrom = final.nixpkgsOnBuildForHost.callPackage ./util/flashrom { };
main = final.callPackage ./main { };

@ -1,40 +1,90 @@
# This takes the output of the `userspace` derivation, plus the
# This constructs a minimal initramfs userspace containing `signify`,
# `lvm`, `dmsetup`, `cryptsetup`, and `kexec`, plus the
# modules from the `kernel` derivation, and creates an
# initramfs-formatted `cpio` archive from their contents.
{ nixpkgsOnBuildForHost
{ lib
, nixpkgsOnBuildForHost
, nixpkgsOnBuildForBuild
, lib
, userspace
, kernel
, bootScript ? ../boot.sh # symlinked to /init if non-null
# a list of paths (relative to ${kernel}/lib/modules/*/kernel) to modules .ko
# files which should be included in the initrd
, modules ? [ ]
, withBusybox ? true
, withSignify ? true
# Inclusion of these is temporarily disabled. I had a bunch of
# ugly space-saving hacks that were removed during the pre-release
# cleanup, and it turns out that without those hacks there isn't enough
# space for the large userspace tools. Once I clean up and
# reinstate those hacks I will reenable this.
, withLvm ? false
, withCryptsetup ? false
, withKexec ? false
, withNvramTool ? false # nixpkgsOnBuildForHost.stdenv.hostPlatform.isx86
}:
nixpkgsOnBuildForHost.stdenv.mkDerivation {
let
inherit (nixpkgsOnBuildForBuild) findutils cpio;
inherit (nixpkgsOnBuildForHost.pkgsStatic) stdenv busybox signify lvm2 cryptsetup kexec-tools;
nvramtool = nixpkgsOnBuildForHost.pkgsStatic.nvramtool.overrideAttrs(a: {
NIX_CFLAGS_COMPILE = "-D__GLIBC__";
});
in stdenv.mkDerivation {
name = "initramfs.cpio";
nativeBuildInputs = with nixpkgsOnBuildForBuild; [ findutils cpio ];
srcs = [ ];
dontUnpack = true;
dontFixup = true;
modulesList = (lib.concatMapStringsSep "\n" (m: "${kernel.version}/kernel/" + m) modules)+"\n";
passAsFile = [ "modulesList" ];
buildPhase = ''
mkdir build
mkdir -p build/lib/modules
BUILD=$(pwd)/build
build=$(pwd)/build
runHook preBuild
mkdir -p $build/lib/modules
pushd ${kernel}/lib/modules/
cat $modulesListPath | cpio -p -d $BUILD/lib/modules
cat $modulesListPath | ${cpio}/bin/cpio -p -d $build/lib/modules
popd
pushd ${userspace}
find . | cpio -p -d $BUILD/
popd
chmod -R u+w $BUILD
pushd $BUILD
find . | cpio --create -H newc -R +0:+0 > $out
mkdir -p $build/usr
ln -s bin $build/sbin
ln -s ../bin $build/usr/bin
ln -s ../sbin $build/usr/sbin
'' + lib.optionalString withBusybox ''
cp -r ${busybox}/bin $build/bin
chmod -R u+w $build/bin
'' + lib.optionalString (bootScript != null) ''
cp ${bootScript} $build/boot.sh
chmod +x $build/boot.sh
ln -s boot.sh $build/init
chmod +x $build/sbin/init
'' + lib.optionalString withSignify ''
cp ${signify}/bin/signify $build/bin/
'' + lib.optionalString withLvm ''
cp ${lib.getBin lvm2}/bin/lvm $build/bin/
cp ${lib.getBin lvm2}/bin/dmsetup $build/bin/
'' + lib.optionalString withCryptsetup ''
cp ${cryptsetup}/bin/cryptsetup $build/bin/
'' + lib.optionalString withKexec ''
cp ${kexec-tools}/bin/kexec $build/bin/
'' + lib.optionalString withNvramTool ''
cp ${nvramtool}/bin/nvramtool $build/bin/
'' + ''
runHook postBuild
'';
installPhase = ''
runHook preInstall
chmod -R u+w $build
pushd $build
${findutils}/bin/find . | ${cpio}/bin/cpio --create -H newc -R +0:+0 > $out
popd
runHook postInstall
'';
dontInstall = true;
passthru = {
inherit modules;

@ -53,8 +53,6 @@ in {
});
inherit modules_insmod;
userspace = prev.userspace.override {
};
initramfs = prev.initramfs.override {
modules = modules_insmod ++ modules_noinsmod;

@ -17,11 +17,11 @@
'';
});
userspace = prev.userspace.overrideAttrs (a: {
postInstall = (a.postInstall or "") + ''
mkdir -p $out/etc
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.layout $out/etc/
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.default $out/etc/
initramfs = prev.initramfs.overrideAttrs (a: {
postBuild = (a.postBuild or "") + ''
mkdir -p $build/etc
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.layout $build/etc/
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.default $build/etc/
'';
});

@ -1,59 +0,0 @@
# This constructs a minimal initramfs userspace containing `signify`,
# `lvm`, `dmsetup`, `cryptsetup`, and `kexec`.
{ lib
, nixpkgsOnBuildForHost
, kernel
, bootScript ? ../boot.sh # symlinked to /init if non-null
, withBusybox ? true
, withSignify ? true
# Inclusion of these is temporarily disabled. I had a bunch of
# ugly space-saving hacks that were removed during the pre-release
# cleanup, and it turns out that without those hacks there isn't enough
# space for the large userspace tools. Once I clean up and
# reinstate those hacks I will reenable this.
, withLvm ? false
, withCryptsetup ? false
, withKexec ? false
, withNvramTool ? false # nixpkgsOnBuildForHost.stdenv.hostPlatform.isx86
}:
let
inherit (nixpkgsOnBuildForHost.pkgsStatic) stdenv busybox signify lvm2 cryptsetup kexec-tools findutils cpio;
nvramtool = nixpkgsOnBuildForHost.pkgsStatic.nvramtool.overrideAttrs(a: {
NIX_CFLAGS_COMPILE = "-D__GLIBC__";
});
in stdenv.mkDerivation {
name = "ownerboot-initramfs-userspace";
dontUnpack = true;
dontFixup = true;
installPhase = ''
runHook preInstall
mkdir -p $out/usr
ln -s bin $out/sbin
ln -s ../bin $out/usr/bin
ln -s ../sbin $out/usr/sbin
'' + lib.optionalString withBusybox ''
cp -r ${busybox}/bin $out/bin
chmod -R u+w $out/bin
'' + lib.optionalString (bootScript != null) ''
cp ${bootScript} $out/boot.sh
chmod +x $out/boot.sh
ln -s boot.sh $out/init
chmod +x $out/sbin/init
'' + lib.optionalString withSignify ''
cp ${signify}/bin/signify $out/bin/
'' + lib.optionalString withLvm ''
cp ${lib.getBin lvm2}/bin/lvm $out/bin/
cp ${lib.getBin lvm2}/bin/dmsetup $out/bin/
'' + lib.optionalString withCryptsetup ''
cp ${cryptsetup}/bin/cryptsetup $out/bin/
'' + lib.optionalString withKexec ''
cp ${kexec-tools}/bin/kexec $out/bin/
'' + lib.optionalString withNvramTool ''
cp ${nvramtool}/bin/nvramtool $out/bin/
'' + ''
runHook postInstall
'';
}
Loading…
Cancel
Save