2024-05-21 21:34:54 +00:00
{ lib
2024-05-21 10:10:04 +00:00
, fetchurl
2024-05-21 21:34:54 +00:00
, linux-megous
, linuxManualConfig
2024-06-09 19:34:07 +00:00
, sane-kernel-tools
2024-05-21 21:34:54 +00:00
, writeTextFile
2024-05-21 10:10:04 +00:00
#v nixpkgs calls `.override` on the kernel to configure additional things, but we don't care about those things
, features ? null
, kernelPatches ? null
, randstructSeed ? " "
2024-05-23 02:07:21 +00:00
, withModemPower ? false
2024-05-21 10:10:04 +00:00
} :
2024-05-21 21:34:54 +00:00
2024-05-21 10:10:04 +00:00
# keep in sync with linux-megous
2024-05-21 21:34:54 +00:00
# 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`
2024-05-21 10:10:04 +00:00
let
2024-05-21 21:34:54 +00:00
pmaportsRef = " 9 8 2 7 9 9 b 9 a 8 3 2 5 9 b 5 9 b 2 5 a 4 1 e 1 9 c a 5 9 1 e 6 3 a e 9 0 6 2 " ;
2024-05-21 10:10:04 +00:00
pmPatch = { name , hash ? " " }: {
inherit name ;
patch = fetchurl {
2024-05-21 21:34:54 +00:00
url = " h t t p s : / / g i t l a b . c o m / p o s t m a r k e t O S / p m a p o r t s / - / r a w / ${ pmaportsRef } / d e v i c e / m a i n / l i n u x - p o s t m a r k e t o s - a l l w i n n e r / ${ name } . p a t c h " ;
2024-05-21 10:10:04 +00:00
inherit hash ;
} ;
} ;
2024-05-21 21:34:54 +00:00
2024-06-09 19:34:07 +00:00
defconfigStr = ( builtins . readFile ./config-postmarketos-allwinner.aarch64 ) + ''
2024-05-21 21:34:54 +00:00
#
# 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
2024-05-22 22:33:40 +00:00
#
# Extra sane-specific options
#
CONFIG_SECURITY_LANDLOCK = y
CONFIG_LSM = " l a n d l o c k , l o c k d o w n , y a m a , l o a d p i n , s a f e s e t i d , s e l i n u x , s m a c k , t o m o y o , a p p a r m o r , b p f " ;
2024-05-23 02:07:21 +00:00
'' + l i b . o p t i o n a l S t r i n g w i t h M o d e m P o w e r ''
CONFIG_MODEM_POWER = y
2024-05-21 21:34:54 +00:00
'' ;
2024-05-21 10:10:04 +00:00
in linuxManualConfig {
inherit ( linux-megous ) extraMakeFlags modDirVersion src version ;
inherit randstructSeed ;
# inherit (linux-megou) kernelPatches;
2024-05-21 21:34:54 +00:00
configfile = writeTextFile {
name = " c o n f i g - p o s t m a r k e t o s - a l l w i n n e r . a a r c h 6 4 " ;
2024-06-09 19:34:07 +00:00
text = defconfigStr ;
2024-05-21 10:10:04 +00:00
} ;
2024-05-21 21:34:54 +00:00
# nixpkgs requires to know the config as an attrset, to do various eval-time assertions.
2024-06-09 19:34:07 +00:00
# this forces me to include the defconfig inline, instead of fetching it the way i do all the other pmOS kernel stuff.
config = sane-kernel-tools . parseDefconfig defconfigStr ;
2024-05-21 21:34:54 +00:00
2024-05-23 02:07:21 +00:00
# these likely aren't *all* required for pinephone: pmOS kernel is shared by many devices
2024-05-21 10:10:04 +00:00
kernelPatches = [
( pmPatch {
name = " 0 0 0 1 - d t s - a d d - d o n t b e e v i l - p i n e p h o n e - d e v k i t " ;
hash = " s h a 2 5 6 - G p J D u S 5 v z G r T 8 y b S E l 0 s / + v P b l r 9 1 7 q u s O A 3 a R W c m o A = " ;
} )
( pmPatch {
name = " 0 0 0 2 - d t s - a d d - p i n e t a b - d e v - o l d - d i s p l a y - p a n e l " ;
hash = " s h a 2 5 6 - e + b T J g y c I 0 D O Y V a s k H X d / O u a z w Z x l f u 0 y W z V l G x i p v o = " ;
} )
( pmPatch {
name = " 0 0 0 3 - d t s - p i n e t a b - a d d - m i s s i n g - o h c i 1 " ;
hash = " s h a 2 5 6 - a C x g l J o 4 o Z a f K x p 2 M j s + A I B 8 v W B U N v v T u B u g Q V l B u 1 A = " ;
} )
( pmPatch {
name = " 0 0 0 4 - d t s - p i n e t a b - m a k e - a u d i o - r o u t i n g - c o n s i s t e n t - w i t h - p i n e p " ;
hash = " s h a 2 5 6 - 0 R 6 9 s i l F s Q k k g N I c S o 4 i K j h F z X T G Q L m a 6 f Z S w A w S j 3 s = " ;
} )
2024-05-23 02:07:21 +00:00
] ++ lib . optionals ( ! withModemPower ) [
2024-05-21 10:10:04 +00:00
( pmPatch {
name = " 0 0 0 5 - d t s - p i n e p h o n e - d r o p - m o d e m - p o w e r - n o d e " ;
hash = " s h a 2 5 6 - 5 9 P d M o 3 h T f S h 1 2 p T I G / V z T S r s D Q d K 1 8 n h + o C t n x v o 5 0 = " ;
} )
2024-05-23 02:07:21 +00:00
] ++ [
2024-05-21 10:10:04 +00:00
( pmPatch {
name = " 0 0 0 6 - d r m - p a n e l - s i m p l e - A d d - H a n n s t a r - T Q T M 0 7 0 C B 5 0 1 " ;
hash = " s h a 2 5 6 - K y s f u h X w p S B U g d D 2 x d 1 I q b F d N z 0 G i G t F b P 1 x D 5 B e B P I = " ;
} )
( pmPatch {
name = " 0 0 0 7 - A R M - d t s - s u n 6 i - A d d - G o C l e v e r - O r i o n - 7 0 L - t a b l e t " ;
hash = " s h a 2 5 6 - i G y 2 o Q g x a 8 H x a u l s D W c A K C U G / y g K 7 g s L 0 g P y L U c D L A I = " ;
} )
( pmPatch {
name = " 0 0 0 8 - d r m - p a n e l - s i m p l e - A d d - H a n n s t a r - H S D 0 7 0 I D W 1 - A " ;
hash = " s h a 2 5 6 - x d Q h 7 z 2 X n 4 5 K u 6 c 5 x q s m Y d F P u t r j k R T i + n f 7 j K l u u 7 4 = " ;
} )
( pmPatch {
name = " 0 0 0 9 - A R M - d t s - s u n 6 i - A d d - L a r k - F r e e M e - 7 0 . 2 S - t a b l e t " ;
hash = " s h a 2 5 6 - c 3 x r t l m S Q w E H t / X k j X H H v x O 9 f f 6 S 3 4 S G x t i e j 6 z d d g w = " ;
} )
( pmPatch {
name = " 0 0 1 0 - e M M C - w o r k a r o u n d " ;
hash = " s h a 2 5 6 - J X F C B A I B e j h G d M S N e f 5 H V i G m J Z 1 R J s c 8 d + + i o T V r j k I = " ;
} )
( pmPatch {
name = " 0 0 1 1 - a r m 6 4 - d t s - a l l w i n n e r - o r a n g e p i - 3 - f i x - e t h e r n e t " ;
hash = " s h a 2 5 6 - v q Z w l M F Q h m A 8 A U f Q D w i 9 l A H p P h t F a O r f + K g H g f B G W g Q = " ;
} )
( pmPatch {
name = " 0 0 1 2 - A R M - d t s - a l l w i n n e r - s u n 5 i - a 1 3 - p o c k e t b o o k - 6 1 4 - p l u s - A d d - " ;
hash = " s h a 2 5 6 - Z G M f b V r 7 s 6 z E S C / B F w o z H c J g R b F + x I n z L k Q a A W l f J 9 w = " ;
} )
] ;
}