summary refs log tree commit diff
path: root/host/initramfs/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-05-10 08:42:24 +0000
committerAlyssa Ross <hi@alyssa.is>2022-05-10 09:33:12 +0000
commit579fd8d9df47f90ce684edda017bf5dc882f258c (patch)
tree50193af524e1aa1922eea82500643169932be6ea /host/initramfs/default.nix
parent8999676304dc81bb257ca28737b584b39c506954 (diff)
downloadspectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.tar
spectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.tar.gz
spectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.tar.bz2
spectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.tar.lz
spectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.tar.xz
spectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.tar.zst
spectrum-579fd8d9df47f90ce684edda017bf5dc882f258c.zip
host/initramfs: install microcode
Diffstat (limited to 'host/initramfs/default.nix')
-rw-r--r--host/initramfs/default.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
index f22f9c8..1ed54fd 100644
--- a/host/initramfs/default.nix
+++ b/host/initramfs/default.nix
@@ -8,6 +8,7 @@
 pkgs.callPackage (
 { lib, stdenv, makeModulesClosure, nixos, runCommand, writeReferencesToFile
 , pkgsStatic, busybox, cpio, cryptsetup, linux-firmware, lvm2
+, microcodeAmd, microcodeIntel
 }:
 
 let
@@ -63,6 +64,16 @@ let
     cp ${pkgsStatic.util-linuxMinimal}/bin/{findfs,lsblk} $out/bin
   '';
 
+  microcode = if stdenv.hostPlatform.isx86_64 then
+    runCommand "microcode.cpio" {
+      nativeBuildInputs = [ cpio ];
+    } ''
+      cpio -id < ${microcodeAmd}/amd-ucode.img
+      cpio -id < ${microcodeIntel}/intel-ucode.img
+      find kernel | cpio -oH newc -R +0:+0 --reproducible > $out
+    ''
+  else null;
+
   packagesCpio = runCommand "packages.cpio" {
     nativeBuildInputs = [ cpio ];
     storePaths = writeReferencesToFile packagesSysroot;
@@ -81,6 +92,7 @@ stdenv.mkDerivation {
     src = cleanSource ./.;
   };
 
+  MICROCODE = microcode;
   PACKAGES_CPIO = packagesCpio;
 
   nativeBuildInputs = [ cpio ];