summaryrefslogtreecommitdiffstats
path: root/configs/hw/framework-13th-gen-intel.nix
blob: 6f605ae67b7c6e2089a02c5cf8934f90e1d9190c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{ config, lib, pkgs, ... }: {

  imports = [
# tv
{
  imports = [
    ../smartd.nix
  ];
  hardware.bluetooth.enable = true;
  hardware.enableRedistributableFirmware = true;
  hardware.graphics.enable = true;
  networking.wireless.enable = true;
  networking.wireless.interfaces = [
    "wlan0"
  ];
  networking.interfaces.wlan0.useDHCP = true;

  # via EV2740X-BK
  networking.interfaces.eth2.useDHCP = true;
  hrm.network.interfaces.eth2.medium = "ethernet";

  nix.settings.cores = 4;
  nixpkgs.hostPlatform = "x86_64-linux";

  services.illum.enable = true;

  services.logind.settings.Login.HandlePowerKey = "suspend";

  system.activationScripts.framework-13th-gen-intel = /* sh */ ''
    echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
  '';

  hrm.lid-handler.enable = true;
}
# tv - Updating Firmware
{
  # sudo fwupdmgr update
  # Latest update: https://fwupd.org/lvfs/devices/work.frame.Laptop.ADL.BIOS.firmware
  services.fwupd.enable = true;
}
# generated hardware-configuration.nix
{
  boot.initrd.availableKernelModules = [
    "nvme"
    "thunderbolt"
    "xhci_pci"
  ];
  boot.initrd.kernelModules = [
    "kvm-intel"
  ];
}
### nixos-hardware/common/cpu/intel/cpu-only.nix
{
  hardware.cpu.intel.updateMicrocode =
    lib.mkDefault config.hardware.enableRedistributableFirmware;
}


### nixos-hardware/common/gpu/intel/default.nix
{
  # VGA compatible controller: Intel Corporation Device a720 (rev 04)
  boot.initrd.kernelModules = [ "i915" ];

  environment.variables = {
    VDPAU_DRIVER = lib.mkIf config.hardware.graphics.enable (lib.mkDefault "va_gl");
  };

  hardware.graphics.extraPackages = [
    pkgs.intel-vaapi-driver
    pkgs.libvdpau-va-gl
    pkgs.intel-media-driver
  ];
}

### nixos-hardware/pc/default.nix
{
  services.libinput.enable = lib.mkDefault true;
}

### nixos-hardware/pc/laptop/default.nix
{
  # Gnome 40 introduced a new way of managing power, without tlp.
  # However, these 2 services clash when enabled simultaneously.
  # https://github.com/NixOS/nixos-hardware/issues/260
  services.tlp.enable =
    lib.mkDefault (!config.services.power-profiles-daemon.enable);
}

### nixos-hardware/pc/laptop/ssd/default.nix
{
  services.fstrim.enable = lib.mkDefault true;
}

### nixos-hardware/framework/13th-gen-intel/default.nix
### nixos-hardware/framework/12th-gen-intel/default.nix
{
  boot.kernelParams = [
    # For Power consumption
    # https://kvark.github.io/linux/framework/2021/10/17/framework-nixos.html
    "mem_sleep_default=deep"
    # For Power consumption
    # https://community.frame.work/t/linux-battery-life-tuning/6665/156
    "nvme.noacpi=1"
    # Workaround iGPU hangs
    # https://discourse.nixos.org/t/intel-12th-gen-igpu-freezes/21768/4
    "i915.enable_psr=1"
  ];

  # This enables the brightness and airplane mode keys to work
  # https://community.frame.work/t/12th-gen-not-sending-xf86monbrightnessup-down/20605/11
  boot.blacklistedKernelModules = [ "hid-sensor-hub" ];

  # Further tweak to ensure the brightness and airplane mode keys work
  # https://community.frame.work/t/responded-12th-gen-not-sending-xf86monbrightnessup-down/20605/67
  systemd.services.bind-keys-driver = {
    description = "Bind brightness and airplane mode keys to their driver";
    wantedBy = [ "default.target" ];
    after = [ "network.target" ];
    serviceConfig = {
      Type = "oneshot";
      User = "root";
    };
    script = ''
      ls -lad /sys/bus/i2c/devices/i2c-*:* /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-*:*
      if [ -e /sys/bus/i2c/devices/i2c-FRMW0001:00 -a ! -e /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-FRMW0001:00 ]; then
        echo fixing
        echo i2c-FRMW0001:00 > /sys/bus/i2c/drivers/i2c_hid_acpi/bind
        ls -lad /sys/bus/i2c/devices/i2c-*:* /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-*:*
        echo done
      else
        echo no fix needed
      fi
    '';
  };

  # Fix TRRS headphones missing a mic
  # https://community.frame.work/t/headset-microphone-on-linux/12387/3
  boot.extraModprobeConfig = ''
    options snd-hda-intel model=dell-headset-multi
  '';

  # For fingerprint support
  services.fprintd.enable = lib.mkDefault true;

  # Custom udev rules
  services.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"
    # Ethernet expansion card support
    ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20"
  '';

  # 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
  hardware.acpilight.enable = lib.mkDefault true;

  # This adds a patched ectool, to interact with the Embedded Controller
  # Can be used to interact with leds from userspace, etc.
  environment.systemPackages = [ pkgs.fw-ectool ];
}

  ];
}