From 549cd6add0087fca7094d5c1577f6d14bc36196e Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 24 Sep 2022 03:07:15 -0700 Subject: [PATCH] initramfs: pass module list as a nix expression rather than a file --- src/initramfs/default.nix | 19 +++++++++++++------ src/platform/kevin/default.nix | 4 ++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/initramfs/default.nix b/src/initramfs/default.nix index 078769d..1f3df04 100644 --- a/src/initramfs/default.nix +++ b/src/initramfs/default.nix @@ -3,8 +3,13 @@ # initramfs-formatted `cpio` archive from their contents. { nixpkgsOnBuildForHost , nixpkgsOnBuildForBuild +, lib , userspace , kernel + +# a list of paths (relative to ${kernel}/lib/modules/*/kernel) to modules .ko +# files which should be included in the initrd +, modules ? [ ] }: nixpkgsOnBuildForHost.stdenv.mkDerivation { @@ -12,20 +17,22 @@ nixpkgsOnBuildForHost.stdenv.mkDerivation { nativeBuildInputs = with nixpkgsOnBuildForBuild; [ findutils cpio ]; srcs = [ ]; dontUnpack = 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 pushd ${kernel}/lib/modules/ - cat ${userspace}/modules-insmod.txt | cpio -p -d $BUILD/lib/modules - popd + cat $modulesListPath | cpio -p -d $BUILD/lib/modules + popd pushd ${userspace} - find . | cpio -p -d $BUILD/ - popd + find . | cpio -p -d $BUILD/ + popd chmod -R u+w $BUILD pushd $BUILD - find . | cpio --create -H newc -R +0:+0 > $out - popd + find . | cpio --create -H newc -R +0:+0 > $out + popd ''; dontInstall = true; } diff --git a/src/platform/kevin/default.nix b/src/platform/kevin/default.nix index eef1c54..9fae447 100644 --- a/src/platform/kevin/default.nix +++ b/src/platform/kevin/default.nix @@ -61,6 +61,10 @@ in { inherit modules_noinsmod; }; + initramfs = prev.initramfs.override { + modules = modules_insmod ++ modules_noinsmod; + }; + coreboot = let atf = final.nixpkgsOnBuildForHost.callPackage (import ./atf) { buildArmTrustedFirmware = (final.nixpkgsOnBuildForHost.callPackage (import ) {