diff --git a/microsoft/surface/default.nix b/microsoft/surface/default.nix index 56dfd07..da01f16 100644 --- a/microsoft/surface/default.nix +++ b/microsoft/surface/default.nix @@ -1,10 +1,15 @@ -{ config, lib, pkgs, ... }: { +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkDefault; + +in { imports = [ ./kernel ./firmware/surface-go/ath10k ]; - boot.extraModprobeConfig = lib.mkDefault '' + boot.extraModprobeConfig = 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 @@ -15,18 +20,25 @@ boot.kernelParams = [ "mem_sleep_default=deep" ]; # NOTE: Check the README before enabling TLP: - services.tlp.enable = lib.mkDefault false; + services.tlp.enable = mkDefault false; # i.e. needed for wifi firmware, see https://github.com/NixOS/nixos-hardware/issues/364 - hardware.enableRedistributableFirmware = lib.mkDefault true; - hardware.sensor.iio.enable = lib.mkDefault true; + hardware.enableRedistributableFirmware = mkDefault true; + hardware.sensor.iio.enable = mkDefault true; - environment.systemPackages = with pkgs; [ surface-control ]; + environment.systemPackages = [ + pkgs.surface-control + ]; users.groups.surface-control = { }; - services.udev.packages = [ pkgs.surface-control ]; + services.udev.packages = [ + pkgs.surface-control + ]; + systemd.services.iptsd = { description = "IPTSD"; script = "${pkgs.iptsd}/bin/iptsd"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ + "multi-user.target" + ]; }; } diff --git a/microsoft/surface/firmware/surface-go/ath10k/ath10k-replace.nix b/microsoft/surface/firmware/surface-go/ath10k/ath10k-replace.nix index be0e4fe..e62307d 100644 --- a/microsoft/surface/firmware/surface-go/ath10k/ath10k-replace.nix +++ b/microsoft/surface/firmware/surface-go/ath10k/ath10k-replace.nix @@ -1,9 +1,10 @@ -{stdenv, lib, pkgs, firmwareLinuxNonfree, ...}: +{ stdenv, lib, pkgs, firmwareLinuxNonfree, ... }: + let repos = (pkgs.callPackage ../../../repos.nix {}); killernetworking_firmware = repos.surface-go-ath10k-firmware_backup + "/K1535_Debian"; -in -stdenv.mkDerivation { + +in stdenv.mkDerivation { pname = "microsoft-surface-go-firmware-linux-nonfree"; inherit (firmwareLinuxNonfree) version; src = firmwareLinuxNonfree; diff --git a/microsoft/surface/firmware/surface-go/ath10k/default.nix b/microsoft/surface/firmware/surface-go/ath10k/default.nix index b23fe2e..f861f8e 100644 --- a/microsoft/surface/firmware/surface-go/ath10k/default.nix +++ b/microsoft/surface/firmware/surface-go/ath10k/default.nix @@ -1,21 +1,24 @@ { config, lib, pkgs, ... }: + let + inherit (lib) mkDefault mkEnableOption mkIf; + cfg = config.hardware.microsoft-surface.firmware.surface-go-ath10k; -in -{ + +in { options = { hardware.microsoft-surface.firmware.surface-go-ath10k = { - replace = lib.mkEnableOption ''Use the "board.bin" firmware for ath10k-based WiFi on Surface Go.''; + replace = mkEnableOption ''Use the "board.bin" firmware for ath10k-based WiFi on Surface Go.''; }; }; - config = lib.mkIf cfg.replace { + config = mkIf cfg.replace { hardware.enableAllFirmware = true; hardware.firmware = [ (pkgs.callPackage ./ath10k-replace.nix {}) ]; - boot.extraModprobeConfig = lib.mkDefault '' + boot.extraModprobeConfig = mkDefault '' options ath10k_core skip_otp=Y ''; }; diff --git a/microsoft/surface/kernel/linux-5.19.17.nix b/microsoft/surface/kernel/linux-5.19.17.nix index 6093c9b..ddd8c91 100644 --- a/microsoft/surface/kernel/linux-5.19.17.nix +++ b/microsoft/surface/kernel/linux-5.19.17.nix @@ -1,7 +1,4 @@ -{ lib, - fetchurl, - repos, -}: +{ lib, fetchurl, repos,}: let inherit (lib) kernel; diff --git a/microsoft/surface/repos.nix b/microsoft/surface/repos.nix index 586d094..b5f3f05 100644 --- a/microsoft/surface/repos.nix +++ b/microsoft/surface/repos.nix @@ -1,4 +1,6 @@ -{ fetchFromGitHub, fetchurl }: { +{ fetchFromGitHub, fetchurl }: + +{ linux-surface = fetchFromGitHub { owner = "linux-surface"; repo = "linux-surface";