{ nixpkgs ? import ./lib/nixpkgs.nix , lib ? import (nixpkgs + "/lib") , pkgsFun ? import nixpkgs , hostPlatform ? null # if left `null` this will be set based on the ./platform/ , six-initrd ? import ../upstream/six-initrd/default.nix , flash-chip-size-in-mbytes ? 16 , images-per-flash-chip ? if flash-chip-size-in-mbytes >= 16 then 2 else 1 }: let nixpkgsArgs = { config.allowNonSource = false; }; nixpkgsOnBuildForBuild = pkgsFun nixpkgsArgs; chip-name = { "16" = "GD25Q128C"; "8" = "GD25Q64C"; }."${toString flash-chip-size-in-mbytes}"; ownerboot = { overlays }: let base = final: prev: { AAAAAASomeThingsBuildTooMuch = throw '' Please don't try to `nix-build` the entire ownerboot scope; there's a lot of stuff in it that need not be built for any particular target. You probably want to add `.main` to your `nix-build -A` argument. ''; inherit hostPlatform; nixpkgsOnBuildForHost = pkgsFun (nixpkgsArgs // (lib.optionalAttrs (final.hostPlatform!=null) { crossSystem = final.hostPlatform; })); coreboot-toolchain = final.callPackage ./coreboot-toolchain { }; # TODO(amjoseph): move this into a `config` attrset console-device = throw "platforms must override this (example: \"ttyS0\")"; console-parameters = "115200n8"; inherit flash-chip-size-in-mbytes images-per-flash-chip; flash-chip-size-in-bytes = flash-chip-size-in-mbytes * 1024 * 1024; image-size-in-bytes = final.flash-chip-size-in-mbytes / final.images-per-flash-chip; linux-command-line = let console = "${final.console-device},${final.console-parameters}"; in "console=${console} earlyprintk=${console}"; iasl_20180531 = final.nixpkgsOnBuildForBuild.callPackage ./coreboot/iasl_20180531 { }; coreboot = final.callPackage ./coreboot { }; image = final.callPackage ./image { }; kernel = final.callPackage ./kernel { }; initramfs = final.callPackage ./initramfs { six-initrd = (six-initrd { inherit (final) lib; pkgsForHost = final.nixpkgsOnBuildForHost; pkgsForBuild = final.nixpkgsOnBuildForBuild; }).minimal; }; flashrom = final.nixpkgsOnBuildForHost.callPackage ./util/flashrom { }; main = final.callPackage ./main { }; scripts = prev.scripts or { # these are default values to be overridden flashrom = throw "platforms must override this attribute"; flash-write-fallback = throw "platforms must override this attribute"; flash-write-normal = throw "platforms must override this attribute"; flash-write-all = throw "platforms must override this attribute"; nextboot-show = throw "platforms must override this attribute"; nextboot-use-fallback = throw "platforms must override this attribute"; nextboot-use-normal = throw "platforms must override this attribute"; em100-write = # currently weakly bound via $PATH because it is often # useful to connect them em100 to a machine belonging to a # totally different platform than the Device Under Test. # TODO(amjoseph): don't hardwire the chip type here '' em100 -v --stop --holdpin float -c ${chip-name} --download ${final.image}/coreboot.rom --start --trace ''; # # TODO(amjoseph): add a sanity check that (a) the image being # written to FALLBACK matches the image currently existing in # NORMAL and (b) the most recent boot was from NORMAL. This # ensures that the user cannot write an untested image to # FALLBACK. I suppose in theory we also need to verify that # NORMAL has not been written to since the most recent boot, but # there's not simple way to check that. }; }; in (lib.makeScope lib.callPackageWith (self: { inherit lib nixpkgsOnBuildForBuild; })).overrideScope' (lib.foldl' lib.composeExtensions (_: prev: prev) ([base] ++ overlays)); common_amd64 = import ./platform/common/amd64.nix { inherit lib; }; common_arm64 = import ./platform/common/arm64.nix { inherit lib; }; in { # one entry for each supported platform kevin = ownerboot (import ./platform/kevin { inherit lib common_arm64; }); am1i = ownerboot (import ./platform/am1i { inherit lib common_amd64; }); kgpe = ownerboot (import ./platform/kgpe { inherit lib common_amd64; }); em100 = nixpkgsOnBuildForBuild.callPackage ./util/em100 { }; }