linux-postmarketos: build in a manner such that nixpkgs eval-time assertions pass

nixpkgs needs to know the config as an actual nix expression => have to vendor the pmos config then
This commit is contained in:
Colin 2024-05-21 21:34:54 +00:00
parent 2640253424
commit 7f71a47d3b
2 changed files with 6795 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,81 @@
{ linux-megous
, linuxManualConfig
{ lib
, fetchurl
, linux-megous
, linuxManualConfig
, writeTextFile
#v nixpkgs calls `.override` on the kernel to configure additional things, but we don't care about those things
, features ? null
, kernelPatches ? null
, randstructSeed ? ""
}:
# keep in sync with linux-megous
# to update: bump the `pmaportsRef` commit, null the hash in pmPatch, and `wget https://gitlab.com/postmarketOS/pmaports/-/raw/$pmaportsRef/device/main/linux-postmarketos-allwinner/config-postmarketos-allwinner.aarch64`
let
pmaportsRef = "982799b9a83259b59b25a41e19ca591e63ae9062";
pmPatch = { name, hash ? "" }: {
inherit name;
patch = fetchurl {
url = "https://gitlab.com/postmarketOS/pmaports/-/raw/982799b9a83259b59b25a41e19ca591e63ae9062/device/main/linux-postmarketos-allwinner/${name}.patch";
url = "https://gitlab.com/postmarketOS/pmaports/-/raw/${pmaportsRef}/device/main/linux-postmarketos-allwinner/${name}.patch";
inherit hash;
};
};
# parseKconfigValue = str: let
# inherit (lib) kernel;
# in
# if str == "y" then
# kernel.yes
# else if str == "m" then
# kernel.module
# else
# # kernel.freeform (lib.removePrefix ''"'' (lib.removeSuffix ''"'' str))
# kernel.freeform str
# ;
parseKconfigLine = line: let
pieces = lib.splitString "=" line;
in
if lib.hasPrefix "#" (lib.head pieces) then [
# this line is a comment.
# N.B.: this could be like `# CONFIG_FOO is not set`, which i might want to report as `n`
] else if lib.length pieces == 1 then [
# no equals sign: this is probably a blank line
] else [{
name = lib.head pieces;
# value = parseKconfigValue (lib.concatStringsSep "=" (lib.tail pieces));
# nixpkgs kernel config is some real fucking bullshit: it wants a plain string here instead of the structured config it demands eeeeeeverywhere else.
value = lib.concatStringsSep "=" (lib.tail pieces);
}]
;
parseKconfig = wholeStr: let
lines = lib.splitString "\n" wholeStr;
parsedItems = lib.concatMap parseKconfigLine lines;
in
lib.listToAttrs parsedItems;
KconfigStr = (builtins.readFile ./config-postmarketos-allwinner.aarch64) + ''
#
# Extra nixpkgs-specific options
# nixos/modules/system/boot/systemd.nix wants CONFIG_DMIID
# nixos/modules/services/networking/firewall-iptables.nix wants CONFIG_IP_NF_MATCH_RPFILTER
#
CONFIG_DMIID=y
CONFIG_IP_NF_MATCH_RPFILTER=y
'';
in linuxManualConfig {
inherit (linux-megous) extraMakeFlags modDirVersion src version;
inherit randstructSeed;
# inherit (linux-megou) kernelPatches;
configfile = fetchurl {
url = "https://gitlab.com/postmarketOS/pmaports/-/raw/982799b9a83259b59b25a41e19ca591e63ae9062/device/main/linux-postmarketos-allwinner/config-postmarketos-allwinner.aarch64";
hash = "sha256-ql6o1tHmu6RUQoCP4J03jaYqbKaHkeE2WZMY6Mti0cs=";
configfile = writeTextFile {
name = "config-postmarketos-allwinner.aarch64";
text = KconfigStr;
};
# nixpkgs requires to know the config as an attrset, to do various eval-time assertions.
# this forces me to include the Kconfig inline, instead of fetching it the way i do all the other pmOS kernel stuff.
config = parseKconfig KconfigStr;
kernelPatches = [
(pmPatch {
name = "0001-dts-add-dontbeevil-pinephone-devkit";