wip/yesman
Milan Pässler 4 years ago
parent 38ab184381
commit 19ac914c4e
  1. 9
      README.md
  2. 8
      configs/boards/t440p.nix
  3. 6
      configs/boards/t60.nix
  4. 6
      configs/boards/x1c.nix
  5. 6
      configs/boards/x220.nix
  6. 9
      configs/boards/x230-fhd.nix
  7. 6
      configs/boards/x230.nix
  8. 4
      configs/boards/x230t.nix
  9. 11
      configs/common.nix
  10. 15
      configs/milan-x1c.nix
  11. 27
      flake.lock
  12. 23
      flake.nix
  13. 44
      modules/coreboot/default.nix
  14. 9
      modules/default.nix
  15. 20
      modules/grub2/default.nix
  16. 73
      pkgs/coreboot-base/default.nix
  17. 2
      pkgs/coreboot-payload-grub2/default.nix
  18. 77
      pkgs/coreboot/default.nix
  19. 7
      pkgs/coreboot/files.nix
  20. 2
      pkgs/overlay.nix
  21. 1
      result

@ -0,0 +1,9 @@
Features:
- Specify config overrides as Nix attribute set
- Change payload without rebuilding coreboot
Limitations:
- currently only `x86_64-linux` host and target systems are supported
- It's not yet possible to build with a SeaBIOS payload

@ -0,0 +1,8 @@
{ ... }:
{
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_THINKPAD_T440P = "y";
# TODO: fetch mrc.bin
}

@ -0,0 +1,6 @@
{ ... }:
{
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_T60 = "y";
}

@ -0,0 +1,6 @@
{ ... }:
{
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X1_CARBON_GEN1 = "y";
}

@ -0,0 +1,6 @@
{ ... }:
{
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X220 = "y";
}

@ -0,0 +1,9 @@
{ ... }:
{
imports = [
./x230.nix
];
# TODO: modify vbt to hide LVDS
}

@ -0,0 +1,6 @@
{ ... }:
{
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X230 = "y";
}

@ -0,0 +1,4 @@
{
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X230T = "y";
}

@ -0,0 +1,11 @@
{ ... }:
{
coreboot.corebootConfig = {
CONFIG_PAYLOAD_NONE = "y"; # payload is added later
CONFIG_CBFS_SIZE = lib.mkDefault "0x300000";
CONFIG_USE_OPTION_TABLE = lib.mkDefault "y";
CONFIG_PCIEXP_CLK_PM = lib.mkDefault "y";
CONFIG_GENERIC_LINEAR_FRAMEBUFFER = lib.mkDefault "y";
};
}

@ -0,0 +1,15 @@
{ ... }:
{
imports = [
./common.nix
./boards/x1c.nix
];
coreboot.corebootConfig = {
CONFIG_LINEAR_FRAMEBUFFER_MAX_WIDTH = "1600";
CONFIG_LINEAR_FRAMEBUFFER_MAX_HEIGHT = "900";
};
grub2.enable = true;
}

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1602333914,
"narHash": "sha256-ossU2LFWerfPK/HkCvAom6WvBrQ80vq9CTApMCPaHMs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b70ac01b380722591c89d40ea31e0ac2463d87ec",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

@ -8,6 +8,27 @@
description = "A collections of derivations for coreboot and payloads";
outputs = { self, nixpkgs }: {
packages = (import ./pkgs/overlay.nix) nixpkgs;
packages.x86_64-linux = let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
(import ./pkgs/overlay.nix)
];
};
inherit (pkgs) lib;
makeDevice = configFile:
with lib.evalModules {
modules = [
./modules
configFile
];
};
system.config.coreboot.rom;
in {
inherit (pkgs) coreboot-payload-grub2 coreboot-payload-tianocore coreboot;
milan-x1c = makeDevice ./configs/milan-x1c.nix;
};
};
}

@ -0,0 +1,44 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.coreboot;
in {
options.coreboot = {
extraFiles = mkOption {
type = types.attrs;
};
corebootConfig = mkOption {
type = types.attrs;
};
rom = mkOption {
readOnly = true;
type = types.path;
};
};
config = {
coreboot.rom = let
base = pkgs.coreboot.override {
inherit (cfg) corebootConfig;
};
filteredFiles = filterAttrs (k: v: v != null) cfg.extraFiles;
filesList = mapAttrsToList (k: v: v // { name = v; }) filteredFiles;
installCommands = concatMapStringsSep "\n" (file: ''
cbfstool $out add \
-f ${file.src} \
-n ${file.name} \
-t ${file.type}
'') filesList;
in runCommand "coreboot-rom" {
buildInputs = with pkgs; [ cbfstool ];
} ''
install -D ${base}/coreboot.rom -t $out
${installCommands}
'';
};
}

@ -0,0 +1,9 @@
{ ... }:
{
imports = [
./coreboot
./grub2
#./tianocore
];
}

@ -0,0 +1,20 @@
{ lib, pkgs, ... }:
with lib;
let
cfg = config.grub2;
in {
options.grub2 = {
enable = mkEnableOption "grub2 coreboot primary payload";
};
config = lib.mkIf cfg.enable {
coreboot.rom.extraFiles = {
"fallback/payload" = {
type = "payload";
src = "${pkgs.coreboot-payload-grub}/default_payload.elf";
};
};
};
}

@ -1,73 +0,0 @@
{ fetchgit
, fetchurl
, stdenv
, m4
, flex
, bison
, zlib
, gnat
, curl
, grub-coreboot
, tianocore-coreboot
, perl
, writeText
, config ? {}
}:
let
version = "4.12";
src = fetchgit {
url = "https://review.coreboot.org/coreboot.git";
rev = "${version}";
fetchSubmodules = true;
sha256 = "1l140zbvn6pkbrr55lymhi4lycimhpy8xgm45shl4zv6a9vjd66z";
};
toolchain = stdenv.mkDerivation rec {
pname = "coreboot-toolchain";
inherit version src;
nativeBuildInputs = [
curl
stdenv
m4
flex
bison
zlib
gnat
];
buildPhase = ''
mkdir -p util/crossgcc/tarballs
${}
NIX_HARDENING_ENABLE="$\{NIX_HARDENING_ENABLE/ format/\}" make crossgcc-i386 CPUS=$NIX_BUILD_CORES
'';
installPhase = ''
cp -r util/crossgcc $out
'';
};
in stdenv.mkDerivation rec {
pname = "coreboot";
inherit version src;
configurePhase = let
filteredConfig = lib.filterAttrs (n: v: v != null) config;
lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig;
configFile = writeText "config" (concatStringsSept "\n" lines);
in ''
cp ${configFile} .config
make olddefconfig
'';
buildPhase = ''
rm -rf util/crossgcc
cp -r ${toolchain} util/crossgcc
chmod u+rwX -R util/crossgcc
patchShebangs util/xcompile/xcompile
make
'';
installPhase = ''
mkdir -p $out
cp build/coreboot.rom $out
'';
passthru = {
inherit toolchain configfile;
};
}

@ -4,7 +4,7 @@
}:
grub2.overrideAttrs (oA: {
name = "coreboot-payload-${oA.name}";
pname = "coreboot-payload-${oA.pname}";
configureFlags = oA.configureFlags ++ [ "--with-platform=coreboot" "--enable-boot-time" ];
postBuild = "make -j $NIX_BUILD_CORES default_payload.elf EXTRA_PAYLOAD_MODULES=\"${lib.concatStringsSep " " extraPayloadModules}\"";
installPhase = "install -D default_payload.elf -t $out";

@ -1,3 +1,76 @@
{ fetchgit
, fetchurl
, stdenv
, m4
, flex
, bison
, zlib
, gnat
, curl
, writeText
, callPackage
, lib
, corebootConfig ? { CONFIG_PAYLOAD_NONE = "y"; }
}:
# ${tianocore-coreboot}/FV/UEFIPAYLOAD.fd
# ${grub-coreboot}/default_payload.elf
let
version = "4.12";
src = fetchgit {
url = "https://review.coreboot.org/coreboot.git";
rev = "${version}";
fetchSubmodules = true;
sha256 = "1l140zbvn6pkbrr55lymhi4lycimhpy8xgm45shl4zv6a9vjd66z";
};
toolchain = stdenv.mkDerivation rec {
pname = "coreboot-toolchain";
inherit version src;
nativeBuildInputs = [
curl
stdenv
m4
flex
bison
zlib
gnat
];
buildPhase = ''
mkdir -p util/crossgcc/tarballs
${lib.concatMapStringsSep "\n" (file: "ln -s ${file.archive} util/crossgcc/tarballs/${file.name}") (callPackage ./files.nix {})}
NIX_HARDENING_ENABLE="$\{NIX_HARDENING_ENABLE/ format/\}" make crossgcc-i386 CPUS=$NIX_BUILD_CORES
'';
installPhase = ''
cp -r util/crossgcc $out
'';
};
filteredConfig = lib.filterAttrs (n: v: v != null) corebootConfig;
lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig;
configFile = writeText "config" (lib.concatStringsSep "\n" lines);
in stdenv.mkDerivation rec {
pname = "coreboot";
inherit version src;
configurePhase = ''
cp ${configFile} .config
make olddefconfig
'';
buildPhase = ''
rm -rf util/crossgcc
cp -r ${toolchain} util/crossgcc
chmod u+rwX -R util/crossgcc
patchShebangs util/xcompile/xcompile
make
'';
installPhase = ''
mkdir -p $out
cp build/coreboot.rom $out
'';
passthru = {
inherit toolchain configFile;
};
}

@ -4,9 +4,10 @@
[
(rec {
version = "6.1.2";
name = "gmp-${version}.tar.xz";
archive = fetchurl {
sha256 = "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7";
url = "mirror://gnu/gmp/gmp-${version}.tar.xz";
url = "mirror://gnu/gmp/${name}";
};
})
@ -48,7 +49,7 @@
(rec {
version = "20200110";
name = "apica-unix2-${version}.tar.gz";
name = "acpica-unix2-${version}.tar.gz";
archive = fetchurl {
sha256 = "1hb4g6r7w8s4bhlkk36fmb4qxghnrwvad7f18cpn6zz0b4sjs7za";
url = "https://acpica.org/sites/acpica/files/${name}";
@ -60,7 +61,7 @@
name = "nasm-${version}.tar.bz2";
archive = fetchurl {
sha256 = "1g409sr1kj7v1089s9kv0i4azvddkcwcypnbakfryyi71b3jdz9l";
url = "https://www.nasm.us/pub/nasm/releasebuilds/${version}.tar.bz2";
url = "https://www.nasm.us/pub/nasm/releasebuilds/${version}/${name}";
};
})
]

@ -1,7 +1,7 @@
final: prev:
let inherit (final) callPackage;
in {
coreboot-base = callPackage ./coreboot-base {};
coreboot = callPackage ./coreboot {};
coreboot-payload-grub2 = callPackage ./coreboot-payload-grub2 {};
coreboot-payload-tianocore = callPackage ./coreboot-payload-tianocore {};
}

@ -0,0 +1 @@
/nix/store/pmmavhwnwrlfsxh9jsm58qx76zc2xl2m-coreboot-4.12
Loading…
Cancel
Save