summaryrefslogtreecommitdiffstats
path: root/lass/1systems/aergia/physical.nix
blob: df310e578435fcbe48b3d7087d84a6f2a56435ff (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
{ config, lib, pkgs, modulesPath, ... }:
{
  imports = [
    ./config.nix
    (modulesPath + "/installer/scan/not-detected.nix")
  ];
  disko.devices = import ./disk.nix;

  networking.hostId = "deadbeef";
  # boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.grub = {
    enable = true;
    device = "/dev/nvme0n1";
    efiSupport = true;
    efiInstallAsRemovable = true;
  };

  boot.kernelPackages = pkgs.linuxPackages_latest;

  boot.kernelParams = [
    # Enable energy savings during sleep
    "mem_sleep_default=deep"
    "initcall_blacklist=acpi_cpufreq_init"

    # for ryzenadj -i
    "iomem=relaxed"
  ];

  # Enables the amd cpu scaling https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html
  # On recent AMD CPUs this can be more energy efficient.
  boot.kernelModules = [ "amd-pstate" "kvm-amd" ];

  # hardware.cpu.amd.updateMicrocode = true;

  services.xserver.videoDrivers = [
    "amdgpu"
  ];

  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" "usb_storage" "sd_mod" ];

  environment.systemPackages = [
    pkgs.vulkan-tools
    pkgs.ryzenadj
    (pkgs.writers.writeDashBin "set_tdp" ''
      set -efux
      watt=$1
      value=$(( $watt * 1000 ))
      ${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit="$value" --fast-limit="$value" --slow-limit="$value"
    '')
  ];

  # textsize
  services.xserver.dpi = 200;
  hardware.video.hidpi.enable = lib.mkDefault true;

  # corectrl
  programs.corectrl.enable = true;
  users.users.mainUser.extraGroups = [ "corectrl" ];

  # use newer ryzenadj
  nixpkgs.config.packageOverrides = super: {
    ryzenadj = super.ryzenadj.overrideAttrs (old: {
      version = "unstable-2023-01-15";
      src = pkgs.fetchFromGitHub {
        owner = "FlyGoat";
        repo = "RyzenAdj";
        rev = "1052fb52b2c0e23ac4cd868c4e74d4a9510be57c"; # unstable on 2023-01-15
        sha256 = "sha256-/IxkbQ1XrBrBVrsR4EdV6cbrFr1m+lGwz+rYBqxYG1k=";
      };
    });
  };
}