You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB
Nix

let
update_microcode = true;
in
{
hostPlatform = (import <nixpkgs/lib>).systems.examples.gnu64;
overlay = (final: prev: {
platform_name = "kgpe";
kernel =
final.lib.makeOverridable (prev.kernel.override {
config = ./linux.config;
buildTargets = [ "bzImage" ];
}).overrideAttrs (a: {
postInstall = (a.postInstall or "") + ''
cp arch/x86_64/boot/bzImage $out
'';
});
userspace = prev.userspace.overrideAttrs (a: {
postInstall = (a.postInstall or "") + ''
cp ${final.coreboot.src}/mainboard/asus/kgpe-d16/cmos.layout $out/etc/
cp ${final.coreboot.src}/mainboard/asus/kgpe-d16/cmos.default $out/etc/
'';
});
coreboot = let
# does include spectre mitigations (performance hit)
#linux-firmware = final.nixpkgsOnBuildForBuild.linux-firmware;
#path-within-linux-firmware = "lib/firmware/amd-ucode/microcode_amd_fam15h.bin";
# does *not* include spectre mitigations (no performance hit)
linux-firmware = final.nixpkgsOnBuildForBuild.fetchgit {
# most recent update that does *not* include spectre
# mitigations; needed for 63xx processors due to an exploitable
# NMI defect in that sieres (only)
url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git";
rev = "5f8ca0c1db6106a2d6d7e85eee778917ff03c3de";
branchName = "main";
#sparseCheckout = path-within-linux-firmware;
hash = "sha256-uwzz0z2+uPke8AVKb80Cy620efdRBSuwjfoIrQhepc8=";
};
path-within-linux-firmware = "amd-ucode/microcode_amd_fam15h.bin";
in
final.lib.makeOverridable (prev.coreboot.override {
iasl = final.iasl_20180531;
payload = "${final.kernel}/bzImage";
fmap = ./custom.fmap;
config = ./coreboot.config;
coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ];
linux-command-line = "console=ttyS1,115200n8";
}).overrideAttrs (a: {
postConfigure = if update_microcode then ''
echo CONFIG_CPU_MICROCODE_MULTIPLE_FILES=y >> .config
'' else ''
echo CONFIG_CPU_MICROCODE_CBFS_NONE=y >> .config
'';
preBuild = final.lib.optionalString update_microcode ''
mkdir -p 3rdparty/blobs/cpu/amd/family_15h/
ln -sfT ${linux-firmware}/${path-within-linux-firmware} \
3rdparty/blobs/cpu/amd/family_15h/microcode_amd_fam15h.bin
mkdir -p 3rdparty/blobs/cpu/amd/family_10h-family_14h/
touch 3rdparty/blobs/cpu/amd/family_10h-family_14h/microcode_amd.bin
'';
postInstall = (a.postInstall or "") + ''
cp src/mainboard/asus/kgpe-d16/cmos.layout $out/
cp src/mainboard/asus/kgpe-d16/cmos.default $out/
'';
});
});
}