dotfiles/hosts/dlaptop/hardware.nix
delta 61f5b3185b
Some checks are pending
laptop / tests (push) Waiting to run
intelnuc / tests (push) Waiting to run
upd :З
2024-08-06 05:38:44 +03:00

235 lines
7.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ stable, unstable, config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.prepend = lib.mkOrder 0 [ "${pkgs.fetchurl {
url = "https://gitlab.freedesktop.org/drm/amd/uploads/9fe228c7aa403b78c61fb1e29b3b35e3/slim7-ssdt";
sha256 = "sha256-Ef4QTxdjt33OJEPLAPEChvvSIXx3Wd/10RGvLfG5JUs=";
name = "slim7-ssdt";
}}" ];
hardware.firmware = [
(pkgs.runCommandNoCC "subwoofer" { } ''
mkdir -p $out/lib/firmware/
cp ${pkgs.fetchurl {
url = "https://raw.githubusercontent.com/darinpp/yoga-slim-7/main/lib/firmware/TAS2XXX38BB.bin";
sha256 = "sha256-qyZxBlnWEnrgbh0crgFf//pKZMTtCqh+CkA+pUNU/+E=";
name = "TAS2XXX38BB.bin";
}} $out/lib/firmware/TAS2XXX38BB.bin
cp ${pkgs.fetchurl {
url = "https://raw.githubusercontent.com/darinpp/yoga-slim-7/main/lib/firmware/TIAS2781RCA4.bin";
sha256 = "sha256-Zj7mwS8DsBinZ8BYvcySc753Aq/xid7vAeQOH/oir6Q=";
name = "TIAS2781RCA4.bin";
}} $out/lib/firmware/TIAS2781RCA4.bin
'')
pkgs.wireless-regdb
];
console = {
earlySetup = true;
font = "${pkgs.spleen}/share/consolefonts/spleen-16x32.psfu";
packages = with pkgs; [ spleen ];
keyMap = "us";
};
boot.initrd = {
preDeviceCommands = ''
cat << "EOF"
____
/\ \
/ \ \
/ \ \
/ \ \
/ /\ \ \
/ / \ \ \
/ / /\ \ \
/ / / \ \ \
/ / /____\___\ \
/ / / \
/ / /________________\
\ / /
\/_____________________/
EOF
echo kernel: $(uname -a | tr -s ' ' ' ' | cut -d' ' -f3,8-12)
'';
};
# boot.initrd = {
# preDeviceCommands = ''/bin/initrd.sh'';
# secrets."/bin/initrd.sh" = ./initrd.sh;
# };
# 5 GHZ wifi
boot.extraModprobeConfig = ''
options cfg80211 ieee80211_regdom="RU"
'';
services.zfs.autoScrub.enable = true;
services.fstrim = {
enable = true;
interval = "weekly";
};
programs.nh = {
enable = true;
clean.enable = true;
clean.extraArgs = "--keep-since 7d --keep 4";
};
boot.loader.systemd-boot.enable = true;
boot.kernelParams = [
"rtc_cmos.use_acpi_alarm=1"
"ideapad_laptop.allow_v4_dytc=1"
"amd_pstate=active"
"initcall_blacklist=acpi_cpufreq_init"
"nowatchdog"
"amd_pstate.shared_mem=1"
"zfs_arc_min=8589934592"
"zfs.zfs_arc_max=25769803776"
"resume=UUID=a2ff20bd-56f3-4c83-b1b4-933ba0c82f36"
# # Disable all mitigations
# "mitigations=off"
# "nopti"
# "tsx=on"
# https://www.phoronix.com/news/Linux-Splitlock-Hurts-Gaming
"split_lock_detect=off"
"acpi_sleep=nonvs"
];
boot.zfs.allowHibernation = true;
boot.zfs.forceImportRoot = false;
boot.resumeDevice = "/dev/mapper/cryptroot0p2";
boot.kernelModules = [ "amd-pstate" "acpi_call" "amdgpu" "kvm-amd" "vfat" "nls_cp437" "nls_iso8859-1" "tcp_bbr" ];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "usbhid" "sd_mod" "vfat" "nls_cp437" "nls_iso8859-1" ];
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.efi.efiSysMountPoint = "/boot";
boot.initrd.kernelModules = [ ];
boot.kernel.sysctl."net.ipv4.tcp_congestion_control" = "bbr";
boot.kernel.sysctl."net.core.default_qdisc" = "fq"; # see https://news.ycombinator.com/item?id=14814530
boot.kernel.sysctl."net.core.wmem_max" = 1073741824; # 1 GiB
boot.kernel.sysctl."net.core.rmem_max" = 1073741824; # 1 GiB
boot.kernel.sysctl."net.ipv4.tcp_rmem" = "4096 87380 1073741824"; # 1 GiB max
boot.kernel.sysctl."net.ipv4.tcp_wmem" = "4096 87380 1073741824"; # 1 GiB max
boot.kernel.sysctl."net.ipv4.tcp_mtu_probing" = 1;
boot.kernel.sysctl."net.ipv4.tcp_fastopen" = 3;
# boot.extraModulePackages = with config.boot.kernelPackages; [ usbip.out acpi_call zfs];
# boot.kernelPackages =
# with builtins; with lib; let
# latestCompatibleVersion = config.boot.zfs.package.latestCompatibleLinuxPackages.kernel.version;
# xanPackages = filterAttrs (name: packages: hasSuffix "_xanmod" name && (tryEval packages).success) pkgs.linuxKernel.packages;
# compatiblePackages = filter (packages: compareVersions packages.kernel.version latestCompatibleVersion <= 0) (attrValues xanPackages);
# orderedCompatiblePackages = sort (x: y: compareVersions x.kernel.version y.kernel.version > 0) compatiblePackages;
# selectedKernelPackage = head orderedCompatiblePackages;
# in selectedKernelPackage // {
# extraPackages = with selectedKernelPackage; [ acpi_call ];
# };
boot.kernelPackages = lib.mkOverride 99 pkgs.linuxPackages_cachyos;
boot.zfs.package = lib.mkOverride 99 pkgs.zfs_cachyos;
chaotic.scx = { enable = true; scheduler = "scx_rusty"; };
environment.systemPackages = [ pkgs.scx ];
boot.extraModulePackages = with config.boot.kernelPackages; [ usbip acpi_call ];
boot.plymouth.enable = false;
boot.supportedFilesystems = [ "zfs" ];
boot.initrd.extraUtilsCommands = ''
copy_bin_and_libs ${pkgs.multipath-tools}/bin/kpartx
'';
boot.initrd.luks = {
yubikeySupport = true;
devices."cryptroot0" = {
device = "/dev/nvme0n1p2";
postOpenCommands = "
kpartx -u /dev/mapper/cryptroot0
kpartx -u /dev/mapper/cryptroot0p1
kpartx -u /dev/mapper/cryptroot0p2
";
yubikey = {
slot = 2;
gracePeriod = 3;
keyLength = 64;
saltLength = 16;
twoFactor = false;
storage = {
device = "/dev/nvme0n1p1";
fsType = "vfat";
path = "/crypt-storage/default";
};
};
};
};
sops.age.keyFile = lib.mkForce "/root/keys.txt";
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/4E0B-6C2F";
fsType = "vfat";
};
fileSystems."/" =
{ device = "zroot/root";
fsType = "zfs";
};
fileSystems."/home" =
{ device = "zroot/home";
fsType = "zfs";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/a2ff20bd-56f3-4c83-b1b4-933ba0c82f36"; }
];
hardware.opengl = {
enable = true;
extraPackages = [ pkgs.amdvlk ];
extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
# package = inputs.hyprland.inputs.nixpkgs.legacyPackages."x86_64-linux".mesa.drivers;
# package32 = inputs.hyprland.inputs.nixpkgs.legacyPackages."x86_64-linux".pkgsi686Linux.mesa.drivers;
};
chaotic.mesa-git.enable = true;
# chaotic.mesa-git.extraPackages = [ pkgs.amdvlk ];
# chaotic.mesa-git.extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
networking.useDHCP = lib.mkDefault true;
networking.hostId = "11C0FFEE";
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
services.logind = {
lidSwitch = "suspend-then-hibernate";
lidSwitchDocked = "ignore";
lidSwitchExternalPower = "ignore";
powerKey = "ignore";
powerKeyLongPress = "hibernate";
extraConfig = ''
IdleAction=suspend-then-hibernate
'';
};
systemd.services.disable-usb-wakeup = {
wantedBy = [ "multi-user.target" ];
script = ''
for usb in /sys/bus/usb/devices/*/power/wakeup; do
echo 'disabled' > $usb
done
'';
};
}