Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
feat: support for Framework 13 AMD (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
realeinherjar committed Nov 19, 2023
1 parent 667278d commit f60c37c
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Read more about this in the [NixOs Paranoid Guide](https://xeiaso.net/blog/paran

## Features

- [XanMod Kernel](https://xanmod.org/)
- [`Hyprland`](https://github.com/hyprwm/Hyprland) Wayland window manager:

- [`Waybar`](https://github.com/Alexays/Waybar) status bar.
Expand Down
14 changes: 7 additions & 7 deletions hosts/laptop-minimal/hardware-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];

boot.initrd.availableKernelModules =
[ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
boot.initrd.availableKernelModules = [
"xhci_pci"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];

fileSystems."/" = {
device = "none";
Expand Down Expand Up @@ -39,6 +41,4 @@
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;

powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
}
52 changes: 42 additions & 10 deletions hosts/laptop/hardware-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];

boot.initrd.availableKernelModules =
[ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];

fileSystems."/" = {
device = "none";
Expand All @@ -23,9 +18,6 @@
fsType = "btrfs";
};

boot.initrd.luks.devices."encryptedroot".device =
"/dev/disk/by-uuid/44795d11-d166-49d7-89e9-62a9945e05f3";

fileSystems."/boot" = {
device = "/dev/disk/by-uuid/5835-50BF";
fsType = "vfat";
Expand All @@ -48,6 +40,46 @@

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;

# Enable AMD/Intel microcode
hardware.enableRedistributableFirmware = true;

# Fix WiFi speeds
hardware.wirelessRegulatoryDatabase = true;

# Needed for desktop environments to detect/manage display brightness
hardware.sensor.iio.enable = lib.mkDefault true;

boot = {
initrd = {
luks.devices."encryptedroot".device =
"/dev/disk/by-uuid/44795d11-d166-49d7-89e9-62a9945e05f3";
availableKernelModules = [
"xhci_pci"
"thunderbolt"
"nvme"
"usb_storage"
"sd_mod"
];
};

# Fix TRRS headphones missing a mic
# https://community.frame.work/t/headset-microphone-on-linux/12387/3
#
# This is temporary until a kernel patch is submitted
extraModprobeConfig = ''
options snd-hda-intel model=dell-headset-multi
'';
};

services = {
auto-cpufreq.enable = true;
thermald.enable = true;
fprintd.enable = lib.mkDefault true;
# Custom udev rules
udev.extraRules = ''
# Ethernet expansion card support
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20"
'';
};
}
18 changes: 8 additions & 10 deletions hosts/laptop/wayland/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, pkgs, user, inputs, ... }:
{ config, pkgs, lib, user, inputs, ... }:

let
user = "einherjar";
Expand Down Expand Up @@ -47,7 +47,7 @@ in
};
boot = {
supportedFilesystems = [ "ntfs" ];
kernelPackages = pkgs.linuxPackages_latest;
kernelPackages = pkgs.linuxPackages_xanmod_latest;
loader = {
systemd-boot = {
enable = true;
Expand All @@ -60,14 +60,12 @@ in
};
timeout = 3;
};
kernelParams = [
"quiet"
"splash"
# framework specific ones
"mem_sleep_default=deep" # better battery life
"nvme.noacpi=1" # better battery life for NVME
"usbcore.quirks=0bda:8156:k" # framework ethernet port not responding after sleep
];

# Fix WiFi speeds
extraModprobeConfig = ''
options cfg80211 ieee80211_regdom="US"
'';

blacklistedKernelModules = [
# Bluetooth
# "btusb"
Expand Down
5 changes: 4 additions & 1 deletion hosts/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
};
openssh = { enable = false; };
fstrim.enable = true;
fwupd.enable = true;
fwupd = {
enable = true;
extraRemotes = [ "lvfs-testing" ];
};
tor.enable = true;
};

Expand Down
36 changes: 36 additions & 0 deletions modules/hardware/amd.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{ config, lib, pkgs, ... }:

{
boot = {
kernelParams = [
"quiet"
"splash"

# framework specific ones
# https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html#active-mode
# note: if you're using 6.1, use "passive"
"amd_pstate=active"
];
# https://git.exozy.me/a/zenpower3
extraModulePackages = with config.boot.kernelPackages; [ zenpower ];
};
services = {
# AMD has better battery life with PPD over TLP:
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
power-profiles-daemon.enable = lib.mkDefault true;
};
hardware = {
cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
opengl = {
enable = true;
extraPackages = with pkgs; [
rocm-opencl-icd
amdvlk
];
};
pulseaudio.support32Bit = true;
};
environment = {
systemPackages = with pkgs; [ glxinfo ];
};
}
3 changes: 2 additions & 1 deletion modules/hardware/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
./intel.nix
# ./intel.nix
./amd.nix
./bluetooth.nix
]
40 changes: 37 additions & 3 deletions modules/hardware/intel.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
{ config, lib, pkgs, ... }:

{
boot = {
kernelModules = [ "kvm-intel" ];
kernelParams = [
"quiet"
"splash"

# framework specific ones
# Fixes a regression in s2idle, making it more power efficient than deep sleep
"acpi_osi=\"!Windows 2020\""
# For Power consumption
# https://kvark.github.io/linux/framework/2021/10/17/framework-nixos.html
"mem_sleep_default=deep"
# Workaround iGPU hangs
# https://discourse.nixos.org/t/intel-12th-gen-igpu-freezes/21768/4
"i915.enable_psr=1"
# better battery life for NVME
"nvme.noacpi=1"
];

# This enables the brightness and airplane mode keys to work
# https://community.frame.work/t/12th-gen-not-sending-xf86monbrightnessup-down/20605/11
blacklistedKernelModules = [ "hid-sensor-hub" ];
};
services = {
tlp = {
enable = true;
Expand Down Expand Up @@ -53,10 +76,16 @@
PLATFORM_PROFILE_ON_BAT = "low-power";
};
};
auto-cpufreq.enable = true;
thermald.enable = true;

# Custom udev rules
udev.extraRules = ''
# Fix headphone noise when on powersave
# https://community.frame.work/t/headphone-jack-intermittent-noise/5246/55
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0xa0e0", ATTR{power/control}="on"
'';
};
hardware = {
cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
opengl = {
enable = true;
extraPackages = with pkgs; [
Expand All @@ -68,9 +97,14 @@
];
};
pulseaudio.support32Bit = true;

# Mis-detected by nixos-generate-config
# https://github.com/NixOS/nixpkgs/issues/171093
# https://wiki.archlinux.org/title/Framework_Laptop#Changing_the_brightness_of_the_monitor_does_not_work
acpilight.enable = lib.mkDefault true;
};
environment = {
systemPackages = with pkgs; [ libva libva-utils glxinfo ];
systemPackages = with pkgs; [ libva libva-utils glxinfo fw-ectool ];
variables = { LIBVA_DRIVER_NAME = "iHD"; };
};
}

0 comments on commit f60c37c

Please sign in to comment.