linux-postmarketos-exynos5: add "optimizeForSize" option

This commit is contained in:
Colin 2024-06-09 18:40:38 +00:00
parent ec29ec76f0
commit 89c9733ed2
2 changed files with 44 additions and 17 deletions

View File

@ -82,7 +82,13 @@ in
# "sbs-manager"
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux-postmarketos-exynos5;
# boot.kernelPackages = with pkgs; linuxPackagesFor (linux-postmarketos-exynos5.override {
# linux = linux_6_6;
# # linux = linux_6_8;
# # linux = linux_6_9;
# optimizeForSize = true;
# });
# boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux-postmarketos-exynos5;
# boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_latest.override {
# structuredExtraConfig = with lib.kernel; {
# CC_OPTIMIZE_FOR_SIZE = lib.mkForce yes;

View File

@ -1,6 +1,7 @@
{ lib
, linux ? linux_6_1, linux_6_1
, linuxManualConfig
, optimizeForSize ? false
, writeTextFile
#v nixpkgs calls `.override` on the kernel to configure additional things
, features ? []
@ -31,26 +32,37 @@ let
in
lib.listToAttrs parsedItems;
KconfigPmos = builtins.readFile ./config-postmarketos-exynos5.arm7;
# remove CONFIG_LOCALVERSION else nixpkgs complains about mismatched modDirVersion
KconfigStr = lib.replaceStrings
[
''CONFIG_LOCALVERSION="-postmarketos-exynos5"''
# ''CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y''
''CONFIG_BATTERY_SBS=y''
]
[
''CONFIG_LOCALVERSION=''
withoutOsFlavor = Kconfig: lib.replaceStrings
[ ''CONFIG_LOCALVERSION="-postmarketos-exynos5"'' ]
[ ''CONFIG_LOCALVERSION='' ]
Kconfig
;
# XXX(2024/06/06): if this module is loaded before udev, then kernel panic.
# see: <repo:NixOS/mobile-nixos:devices/families/mainline-chromeos/default.nix>
withModuleFixes = Kconfig: lib.replaceStrings
[ ''CONFIG_BATTERY_SBS=y'' ]
[ ''CONFIG_BATTERY_SBS=m'' ]
Kconfig
;
withOptimizations = Kconfig: if optimizeForSize then
lib.replaceStrings
[ ''CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y'' ]
# XXX(2024/06/06): if the bzImage is too large, it fails to boot.
# probably an issue with the uboot relocations; not sure exactly what the size limit is.
# XXX(2024/06/08): it now boots fine with the stock optimizations, though the difference in size is only 500KiB (about 10%).
# perhaps this was mis-diagnosed
# ''CONFIG_CC_OPTIMIZE_FOR_SIZE=y''
# XXX(2024/06/06): if this module is loaded before udev, then kernel panic.
# see: <repo:NixOS/mobile-nixos:devices/families/mainline-chromeos/default.nix>
''CONFIG_BATTERY_SBS=m''
]
(builtins.readFile ./config-postmarketos-exynos5.arm7)
+ ''
[ ''CONFIG_CC_OPTIMIZE_FOR_SIZE=y'' ]
Kconfig
else
Kconfig
;
withNixosRequirements = Kconfig: Kconfig + ''
#
# Extra nixpkgs-specific options
# nixos/modules/system/boot/systemd.nix wants CONFIG_DMIID
@ -62,8 +74,17 @@ let
#
CONFIG_SECURITY_LANDLOCK=y
CONFIG_LSM="landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,bpf";
'';
KconfigStr = withNixosRequirements (
withOptimizations (
withModuleFixes (
withoutOsFlavor (
KconfigPmos
)
)
)
);
in linuxManualConfig {
inherit (linux) extraMakeFlags modDirVersion src version;
inherit features randstructSeed;