diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-02-27 02:57:35 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-02-27 03:02:31 +0000 |
commit | ab630003f4951542d7f246f25c11a19dc718bb64 (patch) | |
tree | f62eee9a6e91ad9d6ce6a62d68facd23c3c36dbe | |
parent | 7eb57d645ab60d8e61911c1aebc221cc2b9d98f8 (diff) | |
parent | 115770eed0c0fa50c1277cd0f7fe0f15501dbc43 (diff) | |
download | nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.tar nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.tar.gz nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.tar.bz2 nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.tar.lz nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.tar.xz nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.tar.zst nixlib-ab630003f4951542d7f246f25c11a19dc718bb64.zip |
modules/nixos-hardware: merge 115770eed0c
49 files changed, 1062 insertions, 71 deletions
diff --git a/modules/nixos-hardware/.github/dependabot.yml b/modules/nixos-hardware/.github/dependabot.yml new file mode 100644 index 000000000000..5ace4600a1f2 --- /dev/null +++ b/modules/nixos-hardware/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/modules/nixos-hardware/.github/workflows/test.yml b/modules/nixos-hardware/.github/workflows/test.yml new file mode 100644 index 000000000000..82c79e720c8d --- /dev/null +++ b/modules/nixos-hardware/.github/workflows/test.yml @@ -0,0 +1,15 @@ +name: "Test" +on: + pull_request: + push: +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Show nixpkgs version + run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version' + - run: ./tests/run.py diff --git a/modules/nixos-hardware/.travis.yml b/modules/nixos-hardware/.travis.yml deleted file mode 100644 index 91cf21da023e..000000000000 --- a/modules/nixos-hardware/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: nix -script: - ./tests/run.py diff --git a/modules/nixos-hardware/README.md b/modules/nixos-hardware/README.md index bd5e119a7cd3..12a25e05d1da 100644 --- a/modules/nixos-hardware/README.md +++ b/modules/nixos-hardware/README.md @@ -1,7 +1,9 @@ -NixOS profiles covering hardware quirks. +NixOS profiles to optimize settings for different hardware. ## Setup +### Using channels + Add and update `nixos-hardware` channel: ``` @@ -20,7 +22,46 @@ imports = [ ]; ``` -## Incomplete list of Profiles +New updates to the expressions here will be fetched when you update the channel. + +## Using nix flakes support + +There is also experimental flake support. In your `/etc/nixos/flake.nix` add the following: + +```nix +{ + description = "NixOS configuration with flakes"; + inputs.nixos-hardware.url = github:NixOS/nixos-hardware/master; + + outputs = { self, nixpkgs, nixos-hardware }: { + # replace <your-hostname> with your actual hostname + nixosConfigurations.<your-hostname> = nixpkgs.lib.nixosSystem { + # ... + modules = [ + # ... + # add your model from this list: https://github.com/NixOS/nixos-hardware/blob/master/flake.nix + nixos-hardware.nixosModules.dell-xps-13-9380 + ]; + }; + }; +} +``` + + +### Using fetchGit + +You can fetch the git repository directly: + +```nix +imports = [ + "${builtins.fetchGit { url = "https://github.com/NixOS/nixos-hardware.git"; }}/lenovo/thinkpad/x220" +]; +``` + +Unlike the channel, this will update the git repository on a rebuild. However, +you can easily pin to a particular revision if you desire more stability. + +## List of Profiles See code for all available configurations. @@ -33,24 +74,38 @@ See code for all available configurations. | Apple MacBook Air 6,X | `<nixos-hardware/apple/macbook-air/6>` | | [Apple MacBook Pro 10,1][] | `<nixos-hardware/apple/macbook-pro/10-1>` | | Apple MacBook Pro 12,1 | `<nixos-hardware/apple/macbook-pro/12-1>` | +| Asus TUF FX504GD | `<nixos-hardware/asus/fx504gd>` | | BeagleBoard PocketBeagle | `<nixos-hardware/beagleboard/pocketbeagle>` | +| [Dell G3 3779][] | `<nixos-hardware/dell/g3/3779>` | | Dell Latitude 3480 | `<nixos-hardware/dell/latitude/3480>` | +| Dell Precision 5530 | `<nixos-hardware/dell/precision/5530>` | | [Dell XPS E7240][] | `<nixos-hardware/dell/e7240>` | | [Dell XPS 13 7390][] | `<nixos-hardware/dell/xps/13-7390>` | +| [Dell XPS 13 9343][] | `<nixos-hardware/dell/xps/13-9343>` | | [Dell XPS 13 9360][] | `<nixos-hardware/dell/xps/13-9360>` | | [Dell XPS 13 9370][] | `<nixos-hardware/dell/xps/13-9370>` | | [Dell XPS 13 9380][] | `<nixos-hardware/dell/xps/13-9380>` | | [Dell XPS 15 7590][] | `<nixos-hardware/dell/xps/15-7590>` | | [Dell XPS 15 9550][] | `<nixos-hardware/dell/xps/15-9550>` | +| [Dell XPS 15 9550, nvidia][] | `<nixos-hardware/dell/xps/15-9550/nvidia>` | | [Dell XPS 15 9560][] | `<nixos-hardware/dell/xps/15-9560>` | | [Dell XPS 15 9560, intel only][] | `<nixos-hardware/dell/xps/15-9560/intel>` | | [Dell XPS 15 9560, nvidia only][] | `<nixos-hardware/dell/xps/15-9560/nvidia>` | +| [Dell XPS 15 9500][] | `<nixos-hardware/dell/xps/15-9500>` | +| [Dell XPS 15 9500, nvidia][] | `<nixos-hardware/dell/xps/15-9500/nvidia>` | | [Google Pixelbook][] | `<nixos-hardware/google/pixelbook>` | | [Inverse Path USB armory][] | `<nixos-hardware/inversepath/usbarmory>` | | Lenovo IdeaPad Z510 | `<nixos-hardware/lenovo/ideapad/z510>` | +| Lenovo ThinkPad E470 | `<nixos-hardware/lenovo/thinkpad/e470>` | | Lenovo ThinkPad E495 | `<nixos-hardware/lenovo/thinkpad/e495>` | | Lenovo ThinkPad L13 | `<nixos-hardware/lenovo/thinkpad/l13>` | +| Lenovo ThinkPad L14 (Intel) | `<nixos-hardware/lenovo/thinkpad/l14/intel> | +| Lenovo ThinkPad L14 (AMD) | `<nixos-hardware/lenovo/thinkpad/l14/amd> | | Lenovo ThinkPad P53 | `<nixos-hardware/lenovo/thinkpad/p53>` | +| Lenovo ThinkPad T14 | `<nixos-hardware/lenovo/thinkpad/t14>` | +| Lenovo ThinkPad T14 AMD Gen 1 | `<nixos-hardware/lenovo/thinkpad/t14/amd/gen1>` | +| Lenovo ThinkPad T14s | `<nixos-hardware/lenovo/thinkpad/t14s>` | +| Lenovo ThinkPad T14s AMD Gen 1 | `<nixos-hardware/lenovo/thinkpad/t14s/amd/gen1>` | | Lenovo ThinkPad T410 | `<nixos-hardware/lenovo/thinkpad/t410>` | | Lenovo ThinkPad T420 | `<nixos-hardware/lenovo/thinkpad/t420>` | | Lenovo ThinkPad T430 | `<nixos-hardware/lenovo/thinkpad/t430>` | @@ -62,6 +117,7 @@ See code for all available configurations. | Lenovo ThinkPad T480s | `<nixos-hardware/lenovo/thinkpad/t480s>` | | Lenovo ThinkPad T490 | `<nixos-hardware/lenovo/thinkpad/t490>` | | Lenovo ThinkPad T495 | `<nixos-hardware/lenovo/thinkpad/t495>` | +| Lenovo ThinkPad X113 Yoga | `<nixos-hardware/lenovo/thinkpad/x13-yoga>` | | Lenovo ThinkPad X140e | `<nixos-hardware/lenovo/thinkpad/x140e>` | | Lenovo ThinkPad X220 | `<nixos-hardware/lenovo/thinkpad/x220>` | | Lenovo ThinkPad X230 | `<nixos-hardware/lenovo/thinkpad/x230>` | @@ -70,6 +126,7 @@ See code for all available configurations. | Lenovo ThinkPad X270 | `<nixos-hardware/lenovo/thinkpad/x270>` | | Lenovo ThinkPad X280 | `<nixos-hardware/lenovo/thinkpad/x280>` | | [Lenovo ThinkPad X1 (6th Gen)][] | `<nixos-hardware/lenovo/thinkpad/x1/6th-gen>` | +| [Lenovo ThinkPad X1 (7th Gen)][] | `<nixos-hardware/lenovo/thinkpad/x1/7th-gen>` | | Lenovo ThinkPad X1 Extreme Gen 2 | `<nixos-hardware/lenovo/thinkpad/x1-extreme/gen2>` | | [Microsoft Surface Pro 3][] | `<nixos-hardware/microsoft/surface-pro/3>` | | PC Engines APU | `<nixos-hardware/pcengines/apu>` | @@ -83,9 +140,12 @@ See code for all available configurations. | [Tuxedo InfinityBook v4][] | `<nixos-hardware/tuxedo/infinitybook/v4>` | [Acer Aspire 4810T]: acer/aspire/4810t +[Asus TUF FX504GD]: asus/fx504gd [Apple MacBook Pro 10,1]: apple/macbook-pro/10-1 +[Dell G3 3779]: dell/g3/3779 [Dell XPS E7240]: dell/e7240 [Dell XPS 13 7390]: dell/xps/13-7390 +[Dell XPS 13 9343]: dell/xps/13-9343 [Dell XPS 13 9360]: dell/xps/13-9360 [Dell XPS 13 9370]: dell/xps/13-9370 [Dell XPS 13 9380]: dell/xps/13-9380 @@ -97,16 +157,19 @@ See code for all available configurations. [Google Pixelbook]: google/pixelbook [Inverse Path USB armory]: inversepath/usbarmory [Lenovo ThinkPad X1 (6th Gen)]: lenovo/thinkpad/x1/6th-gen +[Lenovo ThinkPad X1 (7th Gen)]: lenovo/thinkpad/x1/7th-gen +[Lenovo ThinkPad X13 Yoga]: lenovo/thinkpad/x13-yoga [Lenovo ThinkPad X260]: lenovo/thinkpad/x260 [Microsoft Surface Pro 3]: microsoft/surface-pro/3 [Raspberry Pi 2]: raspberry-pi/2 [Samsung Series 9 NP900X3C]: samsung/np900x3c [Purism Librem 13v3]: purism/librem/13v3 -[Purism Librem 13v5]: purism/librem/13v5 +[Purism Librem 15v5]: purism/librem/15v5 [Toshiba Chromebook 2 `swanky`]: toshiba/swanky +[Tuxedo InfinityBook v4]: nixos-hardware/tuxedo/infinitybook/v4 ## How to contribute a new device profile 1. Add your device profile expression in the appropriate directory -2. Link it in the table in README.md +2. Link it in the table in README.md and in flake.nix 3. Run ./tests/run.py to test it. The test script script will parse all the profiles from the README.md diff --git a/modules/nixos-hardware/apple/README.md b/modules/nixos-hardware/apple/README.md new file mode 100644 index 000000000000..c25d9499f425 --- /dev/null +++ b/modules/nixos-hardware/apple/README.md @@ -0,0 +1,11 @@ +## Switching Cmd and Alt/AltGr + +This will switch the left Alt and Cmd key as well as the right Alt/AltGr and Cmd key. + +```nix +boot.kernelParams = [ + "hid_apple.swap_opt_cmd=1" +]; +``` + +Reference: https://wiki.archlinux.org/index.php/Apple_Keyboard#Switching_Cmd_and_Alt/AltGr diff --git a/modules/nixos-hardware/apple/macbook-pro/12-1/README.md b/modules/nixos-hardware/apple/macbook-pro/12-1/README.md new file mode 100644 index 000000000000..6618dc9e5723 --- /dev/null +++ b/modules/nixos-hardware/apple/macbook-pro/12-1/README.md @@ -0,0 +1,15 @@ +# MacBook Pro 12,1 + +## Wireless won't get reconnected after resume/hibernate + +The wifi driver is unloaded before suspend/hibernate to workaround driver issues. +This means it might be required to restart your wifi deamon i.e. wpa_supplicant: + +```nix +powerManagement.powerUpCommands = '' + ${pkgs.systemd}/bin/systemctl restart wpa_supplicant.service +''; +}; +``` + +You can apply this to your network management software of choice. diff --git a/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix b/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix index 02c6f328cf5a..a28ea82f8f95 100644 --- a/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix +++ b/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, pkgs, ... }: { imports = [ @@ -7,6 +7,18 @@ <nixpkgs/nixos/modules/hardware/network/broadcom-43xx.nix> ]; + powerManagement = { + # Enable gradually increasing/decreasing CPU frequency, rather than using + # "powersave", which would keep CPU frequency at 0.8GHz. + cpuFreqGovernor = lib.mkDefault "conservative"; + + # brcmfmac being loaded during hibernation would not let a successful resume + # https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116. + # Also brcmfmac could randomly crash on resume from sleep. + powerUpCommands = lib.mkBefore "${pkgs.kmod}/bin/modprobe brcmfmac"; + powerDownCommands = lib.mkBefore "${pkgs.kmod}/bin/rmmod brcmfmac"; + }; + # USB subsystem wakes up MBP right after suspend unless we disable it. services.udev.extraRules = lib.mkDefault '' SUBSYSTEM=="pci", KERNEL=="0000:00:14.0", ATTR{power/wakeup}="disabled" diff --git a/modules/nixos-hardware/asus/fx504gd/default.nix b/modules/nixos-hardware/asus/fx504gd/default.nix new file mode 100644 index 000000000000..4513250982f8 --- /dev/null +++ b/modules/nixos-hardware/asus/fx504gd/default.nix @@ -0,0 +1,10 @@ +{ ... }: +{ + imports = [ + ../../common/cpu/intel + ../../common/pc/laptop + ]; + + #Nouveau doesn't work at all on this model. + boot.kernelParams = [ "nouveau.modeset=0" ]; +} diff --git a/modules/nixos-hardware/common/gpu/nvidia.nix b/modules/nixos-hardware/common/gpu/nvidia.nix new file mode 100644 index 000000000000..fed9fa98724c --- /dev/null +++ b/modules/nixos-hardware/common/gpu/nvidia.nix @@ -0,0 +1,22 @@ +{ lib, pkgs, ... }: + +# This creates a new 'nvidia-offload' program that runs the application passed to it on the GPU +# As per https://nixos.wiki/wiki/Nvidia +let + nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export __VK_LAYER_NV_optimus=NVIDIA_only + exec -a "$0" "$@" + ''; +in +{ + services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ]; + environment.systemPackages = [ nvidia-offload ]; + + hardware.nvidia.prime = { + offload.enable = lib.mkDefault true; + # Hardware should specify the bus ID for intel/nvidia devices + }; +} diff --git a/modules/nixos-hardware/common/pc/default.nix b/modules/nixos-hardware/common/pc/default.nix index 0b498ff1d20e..8864de1c416a 100644 --- a/modules/nixos-hardware/common/pc/default.nix +++ b/modules/nixos-hardware/common/pc/default.nix @@ -1,5 +1,9 @@ -{ lib, ... }: +{ config, lib, ... }: { + boot.blacklistedKernelModules = lib.optionals (!config.hardware.enableRedistributableFirmware) [ + "ath3k" + ]; + services.xserver.libinput.enable = lib.mkDefault true; } diff --git a/modules/nixos-hardware/common/pc/laptop/default.nix b/modules/nixos-hardware/common/pc/laptop/default.nix index ebc4931dbc29..946d066d04d5 100644 --- a/modules/nixos-hardware/common/pc/laptop/default.nix +++ b/modules/nixos-hardware/common/pc/laptop/default.nix @@ -3,11 +3,5 @@ { imports = [ ../. ]; - # TODO: fix in NixOS/nixpkgs - # Disable governor set in hardware-configuration.nix, - # required when services.tlp.enable is true: - powerManagement.cpuFreqGovernor = - lib.mkIf config.services.tlp.enable (lib.mkForce null); - services.tlp.enable = lib.mkDefault true; } diff --git a/modules/nixos-hardware/dell/g3/3779/default.nix b/modules/nixos-hardware/dell/g3/3779/default.nix new file mode 100644 index 000000000000..8c9b3d328bd0 --- /dev/null +++ b/modules/nixos-hardware/dell/g3/3779/default.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, ... }: + +{ + imports = [ + ../../../common/cpu/intel + ../../../common/gpu/nvidia.nix + ../../../common/pc/laptop + ../../../common/pc/laptop/ssd + ]; + + # Specify bus id of Nvidia and Intel graphics + hardware.nvidia.prime = { + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + + # Cooling management + services.thermald.enable = lib.mkDefault true; + + # Use same ACPI identifier as Dell Ubuntu + boot.kernelParams = [ + "acpi_osi=Linux-Dell-Video" + ]; +} diff --git a/modules/nixos-hardware/dell/precision/5530/default.nix b/modules/nixos-hardware/dell/precision/5530/default.nix new file mode 100644 index 000000000000..52e0dd555425 --- /dev/null +++ b/modules/nixos-hardware/dell/precision/5530/default.nix @@ -0,0 +1,22 @@ +{ lib, pkgs, ... }: + +{ + imports = [ + ../../../common/cpu/intel + ../../../common/pc/laptop + ../../../common/pc/laptop/ssd + ]; + + # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1803179/comments/149 + # fix lspci hanging with nouveau + boot.kernelParams = [ + "acpi_rev_override=1" + "acpi_osi=Linux" + "nouveau.modeset=0" + "pcie_aspm=force" + "drm.vblankoffdelay=1" + "scsi_mod.use_blk_mq=1" + "nouveau.runpm=0" + "mem_sleep_default=deep" + ]; +} diff --git a/modules/nixos-hardware/dell/xps/13-7390/default.nix b/modules/nixos-hardware/dell/xps/13-7390/default.nix index 991e4352cb50..1aa0c4bcd3dd 100644 --- a/modules/nixos-hardware/dell/xps/13-7390/default.nix +++ b/modules/nixos-hardware/dell/xps/13-7390/default.nix @@ -9,5 +9,9 @@ boot.kernelParams = [ "mem_sleep_default=deep" ]; + # older version break wifi: + # - https://github.com/NixOS/nixos-hardware/issues/173 + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.6") pkgs.linuxPackages_latest; + services.thermald.enable = true; } diff --git a/modules/nixos-hardware/dell/xps/13-9343/default.nix b/modules/nixos-hardware/dell/xps/13-9343/default.nix new file mode 100644 index 000000000000..2904a773c7b4 --- /dev/null +++ b/modules/nixos-hardware/dell/xps/13-9343/default.nix @@ -0,0 +1,12 @@ +{ lib, ... }: + +{ + imports = [ + ../../../common/cpu/intel + ../../../common/pc/laptop + ../../../common/pc/laptop/ssd + ]; + + # This will save you money and possibly your life! + services.thermald.enable = lib.mkDefault true; +} diff --git a/modules/nixos-hardware/dell/xps/13-9360/default.nix b/modules/nixos-hardware/dell/xps/13-9360/default.nix index 5ff1e54a46b6..68eedc8c57f5 100644 --- a/modules/nixos-hardware/dell/xps/13-9360/default.nix +++ b/modules/nixos-hardware/dell/xps/13-9360/default.nix @@ -14,16 +14,6 @@ systemd-boot.enable = lib.mkDefault true; }; - hardware.firmware = lib.mkBefore [ pkgs.qca6174-firmware ]; - - # TODO: move to general HiDPI profile - i18n.consoleFont = lib.mkDefault "latarcyrheb-sun32"; # 4K screen, use bigger console font - - # TODO: upstream to NixOS/nixpkgs - nixpkgs.overlays = [(final: previous: { - qca6174-firmware = final.callPackage ./qca6174-firmware.nix {}; - })]; - # This will save you money and possibly your life! services.thermald.enable = true; } diff --git a/modules/nixos-hardware/dell/xps/13-9360/qca6174-firmware.nix b/modules/nixos-hardware/dell/xps/13-9360/qca6174-firmware.nix deleted file mode 100644 index c5da6c183280..000000000000 --- a/modules/nixos-hardware/dell/xps/13-9360/qca6174-firmware.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ stdenv, fetchurl }: - -stdenv.mkDerivation rec { - name = "${target}-firmware-${version}"; - version = "${branch}-00042"; - - branch = "4.4.1.c1"; - target = "QCA6174"; - - src = fetchurl { - url = "https://github.com/kvalo/ath10k-firmware/raw/952afa4949cb34193040cd4e7441e1aee50ac731/${target}/hw3.0/${branch}/firmware-6.bin_RM.${version}-QCARMSWP-1"; - sha256 = "01vvz3qhqw5l3yilcqgk1spk4y9k4qy7na7a57cbl037r231szdh"; - }; - - buildCommand = '' - install -D $src $out/lib/firmware/ath10k/${target}/hw3.0/firmware-6.bin - ''; - - meta = with stdenv.lib; { - description = "Updated firmware for the qca6174 wireless chip"; - homepage = "https://github.com/kvalo/ath10k-firmware/tree/master/QCA6174/hw3.0"; - license = licenses.unfreeRedistributable; - maintainers = with maintainers; [ yorickvp ]; - platforms = platforms.linux; - }; -} diff --git a/modules/nixos-hardware/dell/xps/15-9500/README.wiki b/modules/nixos-hardware/dell/xps/15-9500/README.wiki new file mode 100644 index 000000000000..ebcb5e315396 --- /dev/null +++ b/modules/nixos-hardware/dell/xps/15-9500/README.wiki @@ -0,0 +1,22 @@ += Dell XPS 15 9550 = + +== Tested Hardware == + +* CPU: Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz +* RAM: 64 GB +* HDD: 1 TiB SSD +* Screen: 15" 4k (3840✕2160) +* Graphics: NVIDIA Corporation TU117M [GeForce GTX 1650 Ti Mobile], with Intel Graphics too. +* Input: Touchscreen and trackpad. + +== Notes == + +Also tested with Dell WD19TB Thunderbolt Dock. + +== NVIDIA Offload == + +In order to run a program on the NVIDIA gpu, you can use the `nvidia-offload` function, for example: +``` +nvidia-offload `nix-shell -p glxinfo --run 'glxgears'` +``` +This is a short bash script that sets the proper environment variables and calls your command. diff --git a/modules/nixos-hardware/dell/xps/15-9500/default.nix b/modules/nixos-hardware/dell/xps/15-9500/default.nix new file mode 100644 index 000000000000..c7beda4d558e --- /dev/null +++ b/modules/nixos-hardware/dell/xps/15-9500/default.nix @@ -0,0 +1,21 @@ +{ lib, ... }: +let + thermald-conf = ./thermald-conf.xml; +in +{ + imports = [ + ../../../common/cpu/intel + ../../../common/pc/laptop + ../../../common/pc/laptop/ssd + ]; + + # Boot loader + boot.kernelParams = lib.mkDefault [ "acpi_rev_override" ]; + + # This will save you money and possibly your life! + services.thermald.enable = lib.mkDefault true; + + # Thermald doesn't have a default config for the 9500 yet, the one in this repo + # was generated with dptfxtract-static (https://github.com/intel/dptfxtract) + services.thermald.configFile = lib.mkDefault thermald-conf; +} diff --git a/modules/nixos-hardware/dell/xps/15-9500/nvidia/default.nix b/modules/nixos-hardware/dell/xps/15-9500/nvidia/default.nix new file mode 100644 index 000000000000..451b6eb75315 --- /dev/null +++ b/modules/nixos-hardware/dell/xps/15-9500/nvidia/default.nix @@ -0,0 +1,15 @@ +{ lib, pkgs, ... }: +{ + imports = [ + ../default.nix + ../../../../common/gpu/nvidia.nix + ]; + + hardware.nvidia.prime = { + # Bus ID of the Intel GPU. + intelBusId = lib.mkDefault "PCI:0:2:0"; + + # Bus ID of the NVIDIA GPU. + nvidiaBusId = lib.mkDefault "PCI:1:0:0"; + }; +} diff --git a/modules/nixos-hardware/dell/xps/15-9500/thermald-conf.xml b/modules/nixos-hardware/dell/xps/15-9500/thermald-conf.xml new file mode 100644 index 000000000000..bc13d3541dcb --- /dev/null +++ b/modules/nixos-hardware/dell/xps/15-9500/thermald-conf.xml @@ -0,0 +1,205 @@ +<?xml version="1.0"?> + <!-- BEGIN --> + <ThermalConfiguration> + <Platform> + <Name> Auto generated </Name> + <ProductName>XPS 15 9500</ProductName> + <Preference>QUIET</Preference> + <PPCC> + <PowerLimitIndex>0</PowerLimitIndex> + <PowerLimitMinimum>10000</PowerLimitMinimum> + <PowerLimitMaximum>68000</PowerLimitMaximum> + <TimeWindowMinimum>56000</TimeWindowMinimum> + <TimeWindowMaximum>56000</TimeWindowMaximum> + <StepSize>250</StepSize> + </PPCC> + <ThermalZones> + <ThermalZone> + <Type>auto_zone_0</Type> + <TripPoints> + <TripPoint> + <SensorType>SEN2</SensorType> + <Temperature>55000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + <TargetState>45000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN2</SensorType> + <Temperature>57000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + <TargetState>40000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN2</SensorType> + <Temperature>60000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + <TargetState>35000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN2</SensorType> + <Temperature>64000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + <TargetState>35000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN2</SensorType> + <Temperature>68000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + <TargetState>20000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN2</SensorType> + <Temperature>70000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + <TargetState>15000000</TargetState> + </CoolingDevice> + </TripPoint> + </TripPoints> + </ThermalZone> + <ThermalZone> + <Type>auto_zone_1</Type> + <TripPoints> + <TripPoint> + <SensorType>SEN5</SensorType> + <Temperature>38000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + <TargetState>22000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN5</SensorType> + <Temperature>39000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + <TargetState>17000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN5</SensorType> + <Temperature>40000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + <TargetState>12000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>SEN5</SensorType> + <Temperature>41000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + </CoolingDevice> + </TripPoint> + </TripPoints> + </ThermalZone> + <ThermalZone> + <Type>auto_zone_2</Type> + <TripPoints> + <TripPoint> + <SensorType>VIR1</SensorType> + <Temperature>57000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + <TargetState>15000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>VIR1</SensorType> + <Temperature>60000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>3</SamplingPeriod> + </CoolingDevice> + </TripPoint> + </TripPoints> + </ThermalZone> + <ThermalZone> + <Type>auto_zone_3</Type> + <TripPoints> + <TripPoint> + <SensorType>VIR2</SensorType> + <Temperature>76000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + </CoolingDevice> + </TripPoint> + </TripPoints> + </ThermalZone> + <ThermalZone> + <Type>auto_zone_4</Type> + <TripPoints> + <TripPoint> + <SensorType>WRLS</SensorType> + <Temperature>80000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + </CoolingDevice> + </TripPoint> + </TripPoints> + </ThermalZone> + <ThermalZone> + <Type>auto_zone_5</Type> + <TripPoints> + <TripPoint> + <SensorType>STG1</SensorType> + <Temperature>66000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + <TargetState>19000000</TargetState> + </CoolingDevice> + </TripPoint> + <TripPoint> + <SensorType>STG1</SensorType> + <Temperature>90000</Temperature> + <Type>Passive</Type> + <CoolingDevice> + <Type>B0D4</Type> + <SamplingPeriod>1</SamplingPeriod> + </CoolingDevice> + </TripPoint> + </TripPoints> + </ThermalZone> + </ThermalZones> +</Platform> +</ThermalConfiguration> +<!-- END --> diff --git a/modules/nixos-hardware/dell/xps/15-9550/README.wiki b/modules/nixos-hardware/dell/xps/15-9550/README.wiki index c0e9158a883e..93d33ab9c6f7 100644 --- a/modules/nixos-hardware/dell/xps/15-9550/README.wiki +++ b/modules/nixos-hardware/dell/xps/15-9550/README.wiki @@ -5,12 +5,19 @@ Most of this I presume also applies to the XPS 13 1530, the 13" variant. == Tested Hardware == * CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz -* RAM: 16 GB +* RAM: 32 GB * HDD: 512 GiB SSD * Screen: 15" 4k (3840✕2160) * Graphics: NVIDIA Corporation GM107M, with Intel Graphics too. * Input: Touchscreen and trackpad. +== NVIDIA Offload == + +In order to run a program on the NVIDIA gpu, you can use the `nvidia-offload` function, for example: +``` +nvidia-offload `nix-shell -p glxinfo --run 'glxgears'` +``` +This is a short bash script that sets the proper environment variables and calls your command. == Firmware Configuration == diff --git a/modules/nixos-hardware/dell/xps/15-9550/nvidia/default.nix b/modules/nixos-hardware/dell/xps/15-9550/nvidia/default.nix new file mode 100644 index 000000000000..451b6eb75315 --- /dev/null +++ b/modules/nixos-hardware/dell/xps/15-9550/nvidia/default.nix @@ -0,0 +1,15 @@ +{ lib, pkgs, ... }: +{ + imports = [ + ../default.nix + ../../../../common/gpu/nvidia.nix + ]; + + hardware.nvidia.prime = { + # Bus ID of the Intel GPU. + intelBusId = lib.mkDefault "PCI:0:2:0"; + + # Bus ID of the NVIDIA GPU. + nvidiaBusId = lib.mkDefault "PCI:1:0:0"; + }; +} diff --git a/modules/nixos-hardware/flake.nix b/modules/nixos-hardware/flake.nix new file mode 100644 index 000000000000..f0d24bf41700 --- /dev/null +++ b/modules/nixos-hardware/flake.nix @@ -0,0 +1,91 @@ +{ + description = "nixos-hardware"; + + outputs = { self }: { + nixosModules = { + dell-aspire-4810t = import ./acer/aspire/4810t; + asus-fx504gd = import ./asus/fx504gd; + apple-macbook-air-3 = import ./apple/macbook-air/3; + apple-macbook-air-4 = import apple/macbook-air/4; + apple-macbook-air-6 = import apple/macbook-air/6; + apple-macbook-pro-10-1 = import ./apple/macbook-pro/10-1; + apple-macbook-pro-12-1 = import ./apple/macbook-pro/12-1; + beagleboard-pocketbeagle = import ./beagleboard/pocketbeagle; + dell-g3-3779 = import ./dell/g3/3779; + dell-latitude-3480 = import ./dell/latitude/3480; + dell-precision-5530 = import ./dell/precision/5530; + dell-e7240 = import ./dell/e7240; + dell-xps-13-7390 = import ./dell/xps/13-7390; + dell-xps-13-9343 = import ./dell/xps/13-9343; + dell-xps-13-9360 = import ./dell/xps/13-9360; + dell-xps-13-9370 = import ./dell/xps/13-9370; + dell-xps-13-9380 = import ./dell/xps/13-9380; + dell-xps-15-7590 = import ./dell/xps/15-7590; + dell-xps-15-9550 = import ./dell/xps/15-9550; + dell-xps-15-9550-nvidia = import ./dell/xps/15-9550/nvidia; + dell-xps-15-9560 = import ./dell/xps/15-9560; + dell-xps-15-9560-intel = import ./dell/xps/15-9560/intel; + dell-xps-15-9560-nvidia = import ./dell/xps/15-9560/nvidia; + dell-xps-15-9500 = import ./dell/xps/15-9500; + dell-xps-15-9500-nvidia = import ./dell/xps/15-9500/nvidia; + google-pixelbook = import ./google/pixelbook; + inversepath-usbarmory = import ./inversepath/usbarmory; + lenovo-ideapad-z510 = import ./lenovo/ideapad/z510; + lenovo-thinkpad-e470 = import ./lenovo/thinkpad/e470; + lenovo-thinkpad-e495 = import ./lenovo/thinkpad/e495; + lenovo-thinkpad-l13 = import ./lenovo/thinkpad/l13; + lenovo-thinkpad-l14-intel = import ./lenovo/thinkpad/l14/intel; + lenovo-thinkpad-l14-amd = import ./lenovo/thinkpad/l14/amd; + lenovo-thinkpad-p53 = import ./lenovo/thinkpad/p53; + lenovo-thinkpad-t14 = import ./lenovo/thinkpad/t14; + lenovo-thinkpad-t14-amd-gen1 = import ./lenovo/thinkpad/t14/amd/gen1; + lenovo-thinkpad-t14s = import ./lenovo/thinkpad/t14s; + lenovo-thinkpad-t14s-amd-gen1 = import ./lenovo/thinkpad/t14s/amd/gen1; + lenovo-thinkpad-t410 = import ./lenovo/thinkpad/t410; + lenovo-thinkpad-t420 = import ./lenovo/thinkpad/t420; + lenovo-thinkpad-t430 = import ./lenovo/thinkpad/t430; + lenovo-thinkpad-t440s = import ./lenovo/thinkpad/t440s; + lenovo-thinkpad-t440p = import ./lenovo/thinkpad/t440p; + lenovo-thinkpad-t450s = import ./lenovo/thinkpad/t450s; + lenovo-thinkpad-t460s = import ./lenovo/thinkpad/t460s; + lenovo-thinkpad-t470s = import ./lenovo/thinkpad/t470s; + lenovo-thinkpad-t480s = import ./lenovo/thinkpad/t480s; + lenovo-thinkpad-t490 = import ./lenovo/thinkpad/t490; + lenovo-thinkpad-t495 = import ./lenovo/thinkpad/t495; + lenovo-thinkpad-x140e = import ./lenovo/thinkpad/x140e; + lenovo-thinkpad-x220 = import ./lenovo/thinkpad/x220; + lenovo-thinkpad-x230 = import ./lenovo/thinkpad/x230; + lenovo-thinkpad-x250 = import ./lenovo/thinkpad/x250; + lenovo-thinkpad-x260 = import ./lenovo/thinkpad/x260; + lenovo-thinkpad-x270 = import ./lenovo/thinkpad/x270; + lenovo-thinkpad-x280 = import ./lenovo/thinkpad/x280; + lenovo-thinkpad-x1-6th-gen = import ./lenovo/thinkpad/x1/6th-gen; + lenovo-thinkpad-x1-7th-gen = import ./lenovo/thinkpad/x1/7th-gen; + lenovo-thinkpad-x1-extreme = import ./lenovo/thinkpad/x1-extreme; + lenovo-thinkpad-x13-yoga = import ./lenovo/thinkpad/x13-yoga; + microsoft-surface = import ./microsoft/surface; + microsoft-surface-pro-3 = import ./microsoft/surface-pro/3; + pcengines-apu = import ./pcengines/apu; + raspberry-pi-2 = import ./raspberry-pi/2; + samsung-np900x3c = import ./samsung/np900x3c; + purism-librem-13v3 = import ./purism/librem/13v3; + purism-librem-15v3 = import ./purism/librem/15v3; + supermicro-a1sri-2758f = import ./supermicro/a1sri-2758f; + supermicro-x10sll-f = import ./supermicro/x10sll-f; + thoshiba-swanky = import ./toshiba/swanky; + tuxedo-infinitybook-v4 = import ./tuxedo/infinitybook/v4; + common-cpu-amd = import ./common/cpu/amd; + common-cpu-intel = import ./common/cpu/intel; + common-cpu-intel-kaby-lake = import ./common/cpu/intel/kaby-lake; + common-cpu-intel-sandy-bridge = import ./common/cpu/intel/sandy-bridge; + common-gpu-nvidia = import ./common/gpu/nvidia.nix; + common-pc-hdd = import ./common/pc/hdd; + common-pc-laptop-hdd = import ./common/pc/laptop/hdd; + common-pc-laptop-ssd = import ./common/pc/ssd; + common-pc-laptop-acpi_call = import ./common/pc/laptop/acpi_call.nix; + common-pc-laptop = import ./common/pc/laptop; + common-pc-ssd = import ./common/pc/ssd; + common-pc = import ./common/pc; + }; + }; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/e470/default.nix b/modules/nixos-hardware/lenovo/thinkpad/e470/default.nix new file mode 100644 index 000000000000..c9bf8331b050 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/e470/default.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ../../../common/cpu/intel/kaby-lake + ../../../common/gpu/nvidia.nix + ]; + + hardware.nvidia.prime = { + # Bus ID of the Intel GPU. + intelBusId = lib.mkDefault "PCI:0:2:0"; + + # Bus ID of the NVIDIA GPU. + nvidiaBusId = lib.mkDefault "PCI:1:0:0"; + }; + + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.6") pkgs.linuxPackages_latest; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/l14/amd/default.nix b/modules/nixos-hardware/lenovo/thinkpad/l14/amd/default.nix new file mode 100644 index 000000000000..c2d1534fd178 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/l14/amd/default.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ../../../../common/cpu/amd + ]; + + boot.kernelParams = [ + # With BIOS version 1.12 and the IOMMU enabled, the amdgpu driver + # either crashes or is not able to attach to the GPU depending on + # the kernel version. I've seen no issues with the IOMMU disabled. + # + # BIOS version 1.13 claims to fix IOMMU issues, but we leave the + # IOMMU off to avoid a sad experience for those people that drew + # the short straw when they bought their laptop. + "iommu=off" + ]; + + # As of writing this, Linux 5.8 is the oldest kernel that is still + # supported and has decent Renoir support. + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.8") pkgs.linuxPackages_latest; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/l14/default.nix b/modules/nixos-hardware/lenovo/thinkpad/l14/default.nix new file mode 100644 index 000000000000..e014b7d0fa68 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/l14/default.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ../../../common/pc/laptop/acpi_call.nix + ]; + + boot.kernelParams = [ + # Force use of the thinkpad_acpi driver for backlight control. + # This allows the backlight save/load systemd service to work. + "acpi_backlight=native" + ]; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/l14/intel/default.nix b/modules/nixos-hardware/lenovo/thinkpad/l14/intel/default.nix new file mode 100644 index 000000000000..088289f37c19 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/l14/intel/default.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ../../../../common/cpu/intel + ]; + + services.throttled.enable = lib.mkDefault true; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/t14 b/modules/nixos-hardware/lenovo/thinkpad/t14 new file mode 120000 index 000000000000..7be5dd832dad --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/t14 @@ -0,0 +1 @@ +t14s/ \ No newline at end of file diff --git a/modules/nixos-hardware/lenovo/thinkpad/t14s/amd/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t14s/amd/default.nix new file mode 100644 index 000000000000..2b860e847d65 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/t14s/amd/default.nix @@ -0,0 +1,11 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ../../../../common/cpu/amd + ]; + + # For support of newer AMD GPUs, backlight and internal microphone + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.8") pkgs.linuxPackages_latest; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/t14s/amd/gen1/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t14s/amd/gen1/default.nix new file mode 100644 index 000000000000..cb1ec7d81b76 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/t14s/amd/gen1/default.nix @@ -0,0 +1,8 @@ + +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ]; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/t14s/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t14s/default.nix new file mode 100644 index 000000000000..d783b21a8594 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/t14s/default.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ../. + ../../../common/pc/laptop/acpi_call.nix + ]; + + # For suspending to RAM to work, set Config -> Power -> Sleep State to "Linux" in EFI. + # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Suspend_issues + + # Fingerprint sensor requires a firmware-update to work. + + # Force use of the thinkpad_acpi driver for backlight control. + # This allows the backlight save/load systemd service to work. + boot.kernelParams = [ "acpi_backlight=native" ]; + + # see https://github.com/NixOS/nixpkgs/issues/69289 + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.2") pkgs.linuxPackages_latest; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/x1/7th-gen/audio.nix b/modules/nixos-hardware/lenovo/thinkpad/x1/7th-gen/audio.nix new file mode 100644 index 000000000000..f6ecf58aa337 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/x1/7th-gen/audio.nix @@ -0,0 +1,15 @@ +{ lib, pkgs, ... }: +{ + # This can be removed when the default kernel is at least version 5.6 + # https://github.com/NixOS/nixpkgs/pull/86168 + boot.kernelPackages = lib.mkIf + (lib.versionOlder pkgs.linux.version "5.6") + (lib.mkDefault pkgs.linuxPackages_latest); + + # This can be removed when PulseAudio is at least version 14 + # https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_7)#Audio + hardware.pulseaudio.extraConfig = '' + load-module module-alsa-sink device=hw:0,0 channels=4 + load-module module-alsa-source device=hw:0,6 channels=4 + ''; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/x1/7th-gen/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x1/7th-gen/default.nix new file mode 100644 index 000000000000..8349d05678a2 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/x1/7th-gen/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ../. + ../../../../common/pc/laptop/acpi_call.nix + ./audio.nix + ]; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/x13-yoga/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x13-yoga/default.nix new file mode 100644 index 000000000000..2653910d44b4 --- /dev/null +++ b/modules/nixos-hardware/lenovo/thinkpad/x13-yoga/default.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: { + imports = [ + ../. + ../../../common/cpu/intel + ../../../common/pc/laptop/acpi_call.nix + ../../../common/pc/laptop/ssd + ]; + + # automatic screen orientation + hardware.sensor.iio.enable = true; + + services.xserver.wacom.enable = lib.mkDefault config.services.xserver.enable; +} diff --git a/modules/nixos-hardware/lenovo/thinkpad/x220/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x220/default.nix index 3cf18e397469..b28e27845b0b 100644 --- a/modules/nixos-hardware/lenovo/thinkpad/x220/default.nix +++ b/modules/nixos-hardware/lenovo/thinkpad/x220/default.nix @@ -3,7 +3,7 @@ { imports = [ ../. - ../../../common/cpu/intel + ../../../common/cpu/intel/sandy-bridge ../../../common/pc/laptop/hdd # TODO: reverse compat ../tp-smapi.nix ]; diff --git a/modules/nixos-hardware/lenovo/thinkpad/x260/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x260/default.nix index d64a53075163..c11ef98f79e0 100644 --- a/modules/nixos-hardware/lenovo/thinkpad/x260/default.nix +++ b/modules/nixos-hardware/lenovo/thinkpad/x260/default.nix @@ -5,8 +5,13 @@ ../../../common/pc/laptop/acpi_call.nix ]; + boot.kernelParams = [ + # https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X260#Thinkpad_X260 + "i915.enable_psr=0" + ]; + # https://wiki.archlinux.org/index.php/TLP#Btrfs - services.tlp.extraConfig = '' - SATA_LINKPWR_ON_BAT=med_power_with_dipm - ''; + services.tlp.settings = { + SATA_LINKPWR_ON_BAT = "med_power_with_dipm"; + }; } diff --git a/modules/nixos-hardware/microsoft/surface-pro/3/default.nix b/modules/nixos-hardware/microsoft/surface-pro/3/default.nix index a09c60b1f205..4fa8f79a4135 100644 --- a/modules/nixos-hardware/microsoft/surface-pro/3/default.nix +++ b/modules/nixos-hardware/microsoft/surface-pro/3/default.nix @@ -1,9 +1,4 @@ { lib, ... }: - { - # to use the type cover in the initrd - boot.kernelModules = [ "hid-microsoft" ]; - - # TODO: reverse compat - networking.wireless.enable = lib.mkDefault true; + imports = [ ../../surface ]; } diff --git a/modules/nixos-hardware/microsoft/surface/README.md b/modules/nixos-hardware/microsoft/surface/README.md new file mode 100644 index 000000000000..d67a91e9a161 --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/README.md @@ -0,0 +1,73 @@ +# Derivatives for Microsoft Surface notebooks + +These derivatives use the patches from the [linux-surface repo](https://github.com/linux-surface/linux-surface/tree/master/patches). + +## Kernel + +The kernel needs several patches to make it work correctly with some of the hardware on various +Surface models, e.g. keyboard/trackpad, camera, wifi. + +Not all hardware is fully supported, but the +[linux-surface feature matrix](https://github.com/linux-surface/linux-surface/wiki/Supported-Devices-and-Features#feature-matrix) +provides details on which devices are supported on which types of machine. + +The kernel-specific derivations are under the `kernel/` sub-directory. +In order to simplify maintenance of the Nix code, only the most-recent kernel patch-set is expected +to be maintained in this repo. + +_*NOTE:*_Some built-in Kernel config items need to be set, that aren't set by default: +- https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing + +## Firmware, Drivers and Support Tools + +### WiFi + +For the Surface Go, please see the "Issues" sections below. + +### IPTS + +IPTS is used on most of the Surface range, except for Surface Go and Surface Laptop 3 (AMD version). + +Older kernels used specialised firmware which used a method that's no longer supported by the +more-recent kernels. + +Newer kernels use the kernel-space `intel-precise-touch` driver and user-space `ipstd` daemon. + +The `iptsd` daemon works with the `intel-precise-touch` driver to convert raw touch data from the +kernel-space driver into events for the HID / input sub-system. + +- https://github.com/linux-surface/iptsd +- https://github.com/linux-surface/intel-precise-touch + - _*NOTE:*_ The patches from this repo are included in the above kernel patches, already. + +### DTX, `surface-control` + +*TODO* + +# ToDo's Not Done + +See: [TODO.org](./TODO.org) + +# Issues + +## TLP daemon + +TLP is known to cause problems on Surface unless correctly configured. +See: https://github.com/linux-surface/linux-surface/blob/master/README.md + +## Wifi Firmware for Surface Go + +On the Surface Go, the standard firmware from the official Linux Firmware repo has issues with the +`ath10k` QCA6174 Wifi device. +You will see messages like "Can't ping firmware" *TODO - Copy messages from console* + +The most effective fix to-date is to remove the `board-2.bin` file or replace it with a copy of the +`board.bin` file. + +References: +- https://github.com/jakeday/linux-surface/issues/441 +- https://www.reddit.com/r/SurfaceLinux/comments/e8quqg/surface_go_official_wifi_fix/ +- https://hackmd.io/@dasgeek/ryA5i5Dor +- https://github.com/thebitstick/surfacego-wifi +- https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/ath10k +- https://wireless.wiki.kernel.org/en/users/drivers/ath10k/firmware diff --git a/modules/nixos-hardware/microsoft/surface/TODO.org b/modules/nixos-hardware/microsoft/surface/TODO.org new file mode 100644 index 000000000000..7db7ea42d23d --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/TODO.org @@ -0,0 +1,38 @@ +* Kernel Patching +** DONE Create derivative to patch kernel 5.10.2 + - Latest from linux-surface + - [X] Download github.com/linux-surface/linux-surface kernel patches + - [X] Build kernel using downloaded patches +** TODO Create a function for selecting preferred kernel +** DONE Fix how Keyboard & Trackpad are not being enabled on SL3 + - https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing +* Firmware +** DONE Remove old firmware binaries + - Looks like the ath10k files aren't needed, any more +** DONE Create derivative for `ipts` firmware + - [X] Download github.com/linux-surface/surface-ipts-firmware firmware + - [X] Install the binaries +** DONE Remove `ipts` firmware derivative + - This is only needed on the 4.19 kernel +** TODO Investigate problem with ath10k wifi firmware on Surface Go +*** TODO README entry explaining problem(s) with nonfree firmware on Surface Go +*** TODO Create derivative for `ath10k` firmware on Surface Go + - [X] Download github.com/kvalo/ath10k-firmware ? + - [X] Download kernel.org linux-firmware? + - [ ] Download `board.bin` from Killer Networks? + - [ ] Install ath10k firmware fix for Surface Go + - `board-2.bin` needs to be removed / replaced with `board.bin` +* Support Tools +** TODO Incorporate @hpfr's function(s) from this commit: + - https://github.com/hpfr/system/commit/03fa1b0a83f8a336e812910d0d50f5247a8a630c +** TODO Create derivative for `iptsd` touch-screen daemon + - [ ] Download + - [ ] Install binary + - [ ] Enable via systemd +** TODO Create derivative to patch and rebuild libwacom + - github.com/linux-surface/libwacom-surface + - The plan is to do this in a separate PR against `nixpkgs` instead of `nixos-hardware` +** TODO Create derivative to install `surface-control` + - Download github.com/linux-surface/surface-control +** TODO Create derivative to install `surface-dtx-daemon` + - Download github.com/linux-surface/surface-dtx-daemon diff --git a/modules/nixos-hardware/microsoft/surface/default.nix b/modules/nixos-hardware/microsoft/surface/default.nix new file mode 100644 index 000000000000..7a49d08f945b --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/default.nix @@ -0,0 +1,8 @@ +{ config, lib, pkgs, ... }: +{ + imports = [ + ./kernel + ./firmware + ./hardware_configuration.nix + ]; +} diff --git a/modules/nixos-hardware/microsoft/surface/firmware/default.nix b/modules/nixos-hardware/microsoft/surface/firmware/default.nix new file mode 100644 index 000000000000..67f2ce229214 --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/firmware/default.nix @@ -0,0 +1,6 @@ +{ config, lib, pkgs, ... }: +{ + hardware.enableAllFirmware = true; + hardware.firmware = [ + ]; +} diff --git a/modules/nixos-hardware/microsoft/surface/hardware_configuration.nix b/modules/nixos-hardware/microsoft/surface/hardware_configuration.nix new file mode 100644 index 000000000000..2053b01acd49 --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/hardware_configuration.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: +{ + boot.extraModprobeConfig = lib.mkDefault '' + options i915 enable_fbc=1 enable_rc6=1 modeset=1 + options snd_hda_intel power_save=1 + options snd_ac97_codec power_save=1 + options iwlwifi power_save=Y + options iwldvm force_cam=N + options ath10k_core skip_otp=Y + ''; + + boot.kernelParams = [ "mem_sleep_default=deep" ]; + + # NOTE: Check the README before enabling TLP: + services.tlp.enable = lib.mkDefault false; + + hardware.sensor.iio.enable = lib.mkDefault true; +} diff --git a/modules/nixos-hardware/microsoft/surface/kernel/default.nix b/modules/nixos-hardware/microsoft/surface/kernel/default.nix new file mode 100644 index 000000000000..b280f2d9941c --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/kernel/default.nix @@ -0,0 +1,5 @@ +{ config, lib, pkgs, ... }: + +{ + boot.kernelPackages = pkgs.callPackage ./linux-5.10.2 {}; +} diff --git a/modules/nixos-hardware/microsoft/surface/kernel/linux-5.10.2/default.nix b/modules/nixos-hardware/microsoft/surface/kernel/linux-5.10.2/default.nix new file mode 100644 index 000000000000..d4f6eb4eb9d8 --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/kernel/linux-5.10.2/default.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, ... }: +let + repos = (pkgs.callPackage ../../repos.nix {}); + # TODO: Can I append the path ./patches instead of a string? + patches = repos.linux-surface + "/patches"; + surface_kernelPatches = [ + { name = "microsoft-surface-patches-linux-5.10.2"; + patch = null; + extraConfig = '' + # + # Surface Aggregator Module + # + SURFACE_AGGREGATOR m + SURFACE_AGGREGATOR_ERROR_INJECTION n + SURFACE_AGGREGATOR_BUS y + SURFACE_AGGREGATOR_CDEV m + SURFACE_AGGREGATOR_REGISTRY m + SURFACE_ACPI_NOTIFY m + SURFACE_BATTERY m + SURFACE_DTX m + SURFACE_HID m + SURFACE_PERFMODE m + + # + # These built-in modules are required for the Surface Aggregator Module + # See: https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing + # + SERIAL_DEV_BUS y + SERIAL_DEV_CTRL_TTYPORT y + + # + # Surface Hotplug + # + SURFACE_HOTPLUG m + + # + # IPTS touchscreen + # + # This only enables the user interface for IPTS data. + # For the touchscreen to work, you need to install iptsd. + # + MISC_IPTS m + + # + # Cameras: IPU3 + # + ## TODO: Fix for kernel 5.10.2: + ##VIDEO_IPU3_IMGU m + VIDEO_IPU3_CIO2 m + CIO2_BRIDGE y + INT3472 m + + # + # Cameras: Sensor drivers + # + VIDEO_OV5693 m + ## TODO: Fix for kernel 5.10.2: + ##VIDEO_OV8865 m + + # + # Other Drivers + # + INPUT_SOC_BUTTON_ARRAY m + SURFACE_3_BUTTON m + SURFACE_3_POWER_OPREGION m + SURFACE_PRO3_BUTTON m + SURFACE_GPE m + SURFACE_BOOK1_DGPU_SWITCH m + ''; + } + { + name = "ms-surface/0001-surface3-oemb"; + patch = patches + "/5.10/0001-surface3-oemb.patch"; + } + { + name = "ms-surface/0002-wifi"; + patch = patches + "/5.10/0002-wifi.patch"; + } + { + name = "ms-surface/0003-ipts"; + patch = patches + "/5.10/0003-ipts.patch"; + } + { + name = "ms-surface/0004-surface-gpe"; + patch = patches + "/5.10/0004-surface-gpe.patch"; + } + { + name = "ms-surface/0005-surface-sam-over-hid"; + patch = patches + "/5.10/0005-surface-sam-over-hid.patch"; + } + { + name = "ms-surface/0006-surface-sam"; + patch = patches + "/5.10/0006-surface-sam.patch"; + } + { + name = "ms-surface/0007-surface-hotplug"; + patch = patches + "/5.10/0007-surface-hotplug.patch"; + } + { + name = "ms-surface/0008-surface-typecover"; + patch = patches + "/5.10/0008-surface-typecover.patch"; + } + { + name = "ms-surface/0009-cameras"; + patch = patches + "/5.10/0009-cameras.patch"; + } + ]; +in (with pkgs; recurseIntoAttrs (linuxPackagesFor ( + callPackage ./linux-5.10.2.nix { + kernelPatches = surface_kernelPatches; + } + ))) diff --git a/modules/nixos-hardware/microsoft/surface/kernel/linux-5.10.2/linux-5.10.2.nix b/modules/nixos-hardware/microsoft/surface/kernel/linux-5.10.2/linux-5.10.2.nix new file mode 100644 index 000000000000..411a88d92934 --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/kernel/linux-5.10.2/linux-5.10.2.nix @@ -0,0 +1,18 @@ +{ stdenv, buildPackages, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args: + +with stdenv.lib; + +buildLinux (args // rec { + version = "5.10.2"; + + # modDirVersion needs to be x.y.z, will automatically add .0 if needed + modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; + + # branchVersion needs to be x.y + extraMeta.branch = versions.majorMinor version; + + src = fetchurl { + url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; + sha256 = "18l1ywp99inm90434fm74w8rjfl4yl974kfcpizg2sp2p8xf311v"; + }; +} // (args.argsOverride or {})) diff --git a/modules/nixos-hardware/microsoft/surface/repos.nix b/modules/nixos-hardware/microsoft/surface/repos.nix new file mode 100644 index 000000000000..86424162e399 --- /dev/null +++ b/modules/nixos-hardware/microsoft/surface/repos.nix @@ -0,0 +1,8 @@ +{ lib, pkgs, fetchgit }: +{ + linux-surface = fetchgit { + url="https://github.com/linux-surface/linux-surface.git"; + rev="25ab2cf75e5eda5ab9739db1907300010c06dacf"; + sha256="0h8624d7ix1p6ysw9bllmnnwnv164z8xkx56zj3vdczn91vmqcf9"; + }; +} diff --git a/modules/nixos-hardware/raspberry-pi/2/default.nix b/modules/nixos-hardware/raspberry-pi/2/default.nix index d10bbd2424d9..4774c15fe84f 100644 --- a/modules/nixos-hardware/raspberry-pi/2/default.nix +++ b/modules/nixos-hardware/raspberry-pi/2/default.nix @@ -3,7 +3,6 @@ { boot = { consoleLogLevel = lib.mkDefault 7; - extraTTYs = [ "ttyAMA0" ]; kernelPackages = lib.mkDefault pkgs.linuxPackages_rpi2; kernelParams = [ "dwc_otg.lpm_enable=0" @@ -16,7 +15,7 @@ generationsDir.enable = lib.mkDefault false; raspberryPi = { enable = lib.mkDefault true; - version = lib.mkDefault 2; + version = lib.mkDefault 2; }; }; }; diff --git a/modules/nixos-hardware/tests/run.py b/modules/nixos-hardware/tests/run.py index 653337d19190..2f514d128907 100755 --- a/modules/nixos-hardware/tests/run.py +++ b/modules/nixos-hardware/tests/run.py @@ -1,11 +1,12 @@ #!/usr/bin/env nix-shell -#!nix-shell -p nix -p python3 -i python +#!nix-shell --quiet -p nix -p python3 -i python import argparse import multiprocessing import re import subprocess import sys +from functools import partial from pathlib import Path from typing import List, Tuple @@ -26,25 +27,34 @@ def parse_readme() -> List[str]: return list(profiles) -def build_profile(profile: str) -> Tuple[str, subprocess.CompletedProcess]: +def build_profile( + profile: str, verbose: bool +) -> Tuple[str, subprocess.CompletedProcess]: # Hard-code this for now until we have enough other architectures to care about this. system = "x86_64-linux" if "raspberry-pi/2" in profile: system = "armv7l-linux" cmd = [ - "nix-build", + "nix", + "build", + "-f", + "build-profile.nix", "-I", f"nixos-hardware={ROOT}", - "--dry-run", "--show-trace", - "build-profile.nix", "--system", system, "--arg", "profile", profile, ] + + # uses import from derivation + if profile != "<nixos-hardware/toshiba/swanky>": + cmd += ["--dry-run"] + if verbose: + print(f"$ {' '.join(cmd)}") res = subprocess.run( cmd, cwd=TEST_ROOT, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, ) @@ -60,6 +70,9 @@ def parse_args() -> argparse.Namespace: help="Number of parallel evaluations." "If set to 1 it disable multi processing (suitable for debugging)", ) + parser.add_argument( + "--verbose", action="store_true", help="Print evaluation commands executed", + ) parser.add_argument("profiles", nargs="*") return parser.parse_args() @@ -84,12 +97,13 @@ def main() -> None: print(f"{RED}{res.stderr.rstrip()}{RESET}", file=sys.stderr) failed_profiles.append(profile) + build = partial(build_profile, verbose=args.verbose) if len(profiles) == 0 or args.jobs == 1: for profile in profiles: - eval_finished(build_profile(profile)) + eval_finished(build(profile)) else: pool = multiprocessing.Pool(processes=args.jobs) - for r in pool.imap(build_profile, profiles): + for r in pool.imap(build, profiles): eval_finished(r) if len(failed_profiles) > 0: print(f"\n{RED}The following {len(failed_profiles)} test(s) failed:{RESET}") |