2024-04-28 11:54:53 -04:00
# Surface Pro 9
2024-05-07 18:02:59 -04:00
{
config ,
lib ,
pkgs ,
modulesPath ,
. . .
} :
2024-07-03 15:10:33 -04:00
let
bootUUID = " B 2 D 7 - 9 6 C 3 " ; # The UUID of the boot partition.
luksUUID = " f 5 f f 3 9 1 a - f 2 e f - 4 a c 3 - 9 c e 8 - 9 f 5 e d 9 5 0 b 2 1 2 " ; # The UUID of the locked LUKS partition.
in
2024-05-07 18:02:59 -04:00
{
imports = [ ( modulesPath + " / i n s t a l l e r / s c a n / n o t - d e t e c t e d . n i x " ) ] ;
boot = {
2024-08-27 17:40:47 -04:00
# NOTE: Uncomment to use a default kernel and skip full kernel rebuilds
#kernelPackages = lib.mkForce pkgs.linuxPackages_latest;
2024-09-14 11:19:55 -04:00
# NOTE: Loading the camera driver results in a kernel panic on 6.10 kernels. See https://github.com/linux-surface/linux-surface/issues/1516
blacklistedKernelModules = [
" i n t e l - i p u 6 "
" i n t e l - i p u 6 - i s y s "
] ;
2024-08-12 20:09:08 -04:00
# Enable antenna aggregation
extraModprobeConfig = ''
options iwlwifi 1 1 n_disable = 8
'' ;
2024-05-07 18:02:59 -04:00
initrd = {
availableKernelModules = [
" s u r f a c e _ a g g r e g a t o r "
" s u r f a c e _ a g g r e g a t o r _ r e g i s t r y "
" s u r f a c e _ a g g r e g a t o r _ h u b "
" s u r f a c e _ h i d _ c o r e "
" h i d _ m u l t i t o u c h "
" 8 2 5 0 _ d w "
" i n t e l _ l p s s "
" i n t e l _ l p s s _ p c i "
" x h c i _ p c i "
" t h u n d e r b o l t "
" n v m e "
" u s b _ s t o r a g e "
" s d _ m o d "
" s u r f a c e _ k b d "
" p i n c t r l _ t i g e r l a k e "
] ;
kernelModules = [
" s u r f a c e _ a g g r e g a t o r "
" s u r f a c e _ a g g r e g a t o r _ r e g i s t r y "
" s u r f a c e _ a g g r e g a t o r _ h u b "
" s u r f a c e _ h i d _ c o r e "
" s u r f a c e _ h i d "
" h i d _ m u l t i t o u c h "
" 8 2 5 0 _ d w "
" i n t e l _ l p s s "
" i n t e l _ l p s s _ p c i "
" s u r f a c e _ k b d "
" p i n c t r l _ t i g e r l a k e "
] ;
} ;
2024-06-21 14:26:32 -04:00
kernel . sysctl = {
# Try to reduce swappiness - Khanda hates paging, even to NVMe storage
" v m . s w a p p i n e s s " = 20 ;
} ;
2024-05-07 18:02:59 -04:00
kernelModules = [
" k v m - i n t e l "
" s u r f a c e _ a g g r e g a t o r "
" s u r f a c e _ a g g r e g a t o r _ r e g i s t r y "
" s u r f a c e _ a g g r e g a t o r _ h u b "
" s u r f a c e _ h i d _ c o r e "
" s u r f a c e _ h i d "
" h i d _ m u l t i t o u c h "
" 8 2 5 0 _ d w "
" i n t e l _ l p s s "
" i n t e l _ l p s s _ p c i "
" s u r f a c e _ k b d "
" p i n c t r l _ t i g e r l a k e "
] ;
2024-08-17 15:33:12 -04:00
2024-09-02 15:11:27 -04:00
kernelParams = [
2024-09-03 11:53:45 -04:00
" p c i = h p i o s i z e = 0 " # Prevent ACPI interrupt storm. See https://github.com/linux-surface/linux-surface/wiki/Surface-Pro-9#acpi-interrupt-storm
2024-09-03 11:52:38 -04:00
" n v m e _ c o r e . d e f a u l t _ p s _ m a x _ l a t e n c y _ u s = 0 " # Disable NVME powersaving to prevent system stuttering. See https://forums.linuxmint.com/viewtopic.php?t=392387
2024-09-03 11:53:45 -04:00
] ;
2024-05-07 18:02:59 -04:00
} ;
2024-07-03 15:10:33 -04:00
# Configure the main filesystem.
2024-07-03 21:13:13 -04:00
aux . system . filesystem = {
2024-07-05 09:36:11 -04:00
enable = true ;
partitions = {
boot = " / d e v / d i s k / b y - u u i d / ${ bootUUID } " ;
luks = " / d e v / d i s k / b y - u u i d / ${ luksUUID } " ;
2024-05-07 18:02:59 -04:00
} ;
2024-07-05 09:36:11 -04:00
swapFile = {
2024-07-03 15:10:33 -04:00
enable = true ;
2024-07-05 09:36:11 -04:00
size = 16384 ;
2024-05-07 18:02:59 -04:00
} ;
} ;
2024-07-07 10:48:51 -04:00
# Change I/O scheduler to BFQ to try and reduce stuttering under load.
services . udev . extraRules = ''
ACTION == " a d d | c h a n g e " , KERNEL == " n v m e 0 * " , ATTR { queue/rotational } == " 0 " , ATTR { queue/scheduler } = " b f q "
'' ;
2024-06-08 14:36:28 -04:00
hardware = {
cpu . intel . updateMicrocode = lib . mkDefault config . hardware . enableRedistributableFirmware ;
2024-08-17 15:33:12 -04:00
ipu6 = {
2024-09-10 18:45:36 -04:00
enable = true ;
2024-08-17 15:33:12 -04:00
platform = " i p u 6 e p " ;
} ;
2024-06-08 14:36:28 -04:00
} ;
2024-05-07 18:02:59 -04:00
2024-08-27 17:40:47 -04:00
# Limit the number of cores Nix can use
nix . settings . cores = 8 ;
2024-05-07 18:02:59 -04:00
# Install/configure additional drivers, particularly for touch
environment . systemPackages = with pkgs ; [ libwacom-surface ] ;
2024-04-23 14:46:17 -04:00
}