dotfiles/hosts/dlaptop/hardware.nix
2024-06-04 17:03:55 +00:00

156 lines
4.8 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
];
# 5 GHZ wifi
boot.extraModprobeConfig = ''
options cfg80211 ieee80211_regdom="RU"
'';
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"
];
boot.kernelModules = [ "amd-pstate" "acpi_call" "amdgpu" "kvm-amd" "vfat" "nls_cp437" "nls_iso8859-1" ];
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.extraModulePackages = with config.boot.kernelPackages; [ usbip.out ];
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;
in head orderedCompatiblePackages;
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 = 7;
keyLength = 64;
saltLength = 16;
twoFactor = false;
storage = {
device = "/dev/nvme0n1p1";
fsType = "vfat";
path = "/crypt-storage/default";
};
};
};
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/4E0B-6C2F";
fsType = "vfat";
};
fileSystems."/" =
{ device = "zroot/ROOT/default";
fsType = "zfs";
};
fileSystems."/nix/store" =
{ device = "zroot/nix/store";
fsType = "zfs";
};
fileSystems."/var/log" =
{ device = "zroot/var/log";
fsType = "zfs";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/a2ff20bd-56f3-4c83-b1b4-933ba0c82f36"; }
];
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = 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;
};
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";
# lidSwitchDocked = "ignore";
# lidSwitchExternalPower = "ignore";
# powerKey = "ignore";
# powerKeyLongPress = "reboot";
#};
}