about summary refs log tree commit diff
path: root/users/glittershark/system/system/machines/chupacabra.nix
blob: 242c2865601c8c544caa8799421438ad3827605d (plain) (blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{ config, lib, pkgs, ... }:

{
  imports = [
    ../modules/common.nix
    ../modules/reusable/battery.nix
    ../modules/tvl.nix
    ../modules/urbint.nix
    ../modules/fcitx.nix
    ../modules/rtlsdr.nix
    ../../../../../ops/nixos/v4l2loopback.nix
  ];

  hardware.enableRedistributableFirmware = true;

  networking.hostName = "chupacabra";

  powerManagement = {
    enable = true;
    powertop.enable = true;
  };

  laptop.onLowBattery = {
    enable = true;
    action = "hibernate";
    thresholdPercentage = 5;
  };

  boot = {
    blacklistedKernelModules = [ "nouveau" "intel" ];
    extraModulePackages = [ ];

    initrd = {
      availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
      kernelModules = [ ];

      luks.devices = {
        "cryptroot".device = "/dev/disk/by-uuid/c2fc7ce7-a45e-48a1-8cde-be966ef601db";
        "cryptswap".device = "/dev/disk/by-uuid/3b6e2fd4-bfe9-4392-a6e0-4f3b3b76e019";
      };
    };

    kernel.sysctl."vm.swappiness" = 1;
    kernelModules = [ "kvm-intel" ];
    kernelParams = [ "acpi_rev_override" ];
  };

  services.thermald.enable = true;

  hardware.cpu.intel.updateMicrocode = true;

  # Intel-only graphics
  hardware.nvidiaOptimus.disable = true;
  services.xserver.videoDrivers = [ "intel" ];

  # Nvidia Optimus (hybrid) - currently not working
  # services.xserver.videoDrivers = [ "intel" "nvidia" ];
  # boot.blacklistedKernelModules = [ "nouveau" "bbswitch" ];
  # boot.extraModulePackages = [ pkgs.linuxPackages.nvidia_x11 ];
  # hardware.bumblebee.enable = true;
  # hardware.bumblebee.pmMethod = "none";

  systemd.services.disable-usb-autosuspend = {
    description = "Disable USB autosuspend";
    wantedBy = [ "multi-user.target" ];
    serviceConfig = { Type = "oneshot"; };
    unitConfig.RequiresMountsFor = "/sys";
    script = ''
      echo -1 > /sys/module/usbcore/parameters/autosuspend
    '';
  };

  # From hardware-configuration.nix

  fileSystems."/" =
    { device = "/dev/mapper/cryptroot";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/3492-9E3A";
      fsType = "vfat";
    };

  swapDevices =
    [ { device = "/dev/disk/by-uuid/caa7e2ff-475b-4024-b29e-4f88f733fc4c"; }
    ];

  nix.maxJobs = lib.mkDefault 12;
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  # High-DPI console
  console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";

  # from nixos-hardware TODO sort this around
  services.tlp.enable = true;
  services.fstrim.enable = lib.mkDefault true;

  # Intel cpu stuff
  hardware.opengl.extraPackages = with pkgs; [
    vaapiIntel
    vaapiVdpau
    libvdpau-va-gl
    intel-media-driver
  ];

  services.udev.extraRules = ''
    # UDEV rules for Teensy USB devices
    ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1"
    ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", MODE:="0666"
    KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", MODE:="0666"
  '';

  # Necessary to get steam working
  hardware.opengl.driSupport32Bit = true;
}