summaryrefslogtreecommitdiff
path: root/configurations/melian/default.nix
blob: bfdc42e1efea056087fd77fca66ac7194d0b71ef (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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; {
  nixfiles.modules = {
    games = {
      lutris.enable = true;
      steam.enable = true;
    };

    wireguard.client.enable = true;

    syncthing.enable = true;

    android.enable = true;
    beets.enable = true;
    bluetooth.enable = true;
    libvirtd.enable = true;
    mpd.enable = true;
    qutebrowser.enable = true;

    throttled.enable = true;
  };

  networking = {
    interfaces = {
      eth0.useDHCP = true;
      wlan0.useDHCP = true;
    };

    networkmanager = {
      enable = true;
      wifi.backend = "iwd";

      # Spent three days trying to make this work but still getting "No SSO
      # handler" even on the HEAD version that 100% has SSO support baked in.
      # It's all so tiresome[1]... aaand KDE is not supported[2].
      #
      # I fucking hate AnyConnect, truly an example of how shit is is non-free
      # software. SAML also sucks balls. I also hate my company for using this
      # shit, guess I have no other choice but to use the absolute dogshit
      # Ubuntu laptop they gave me.
      #
      # [1]: https://gitlab.gnome.org/GNOME/NetworkManager-openconnect
      # [1]: https://gitlab.com/openconnect/openconnect/-/issues/424
      # [2]: https://groups.google.com/g/linux.debian.bugs.dist/c/lK8u-LMY7n4
      # [2]: https://bugs.kde.org/show_bug.cgi?id=448153
      #
      # plugins = with pkgs; [
      #   ((networkmanager-openconnect.override {
      #     withGnome = false;
      #     openconnect = openconnect.overrideAttrs (_: super: {
      #       version = "unstable-2022-10-23";
      #       src = fetchFromGitLab {
      #         owner = "openconnect";
      #         repo = "openconnect";
      #         rev = "acdfc753f7885b2a539f99036ac41ba1b78cc7ae";
      #         hash = "sha256-ub+Z4WFD77h5YMQTb+TLc7EyY2KjBWglF1QVTirCHJM=";
      #       };
      #     });
      #   }).overrideAttrs (_: super: {
      #     version = "unstable-2022-09-10";
      #     src = fetchFromGitLab {
      #       domain = "gitlab.gnome.org";
      #       owner = "GNOME";
      #       repo = "NetworkManager-openconnect";
      #       rev = "3c1590786518e9acca33c250660ad21cae565acd";
      #       hash = "sha256-YTUN46QHsHkXPAhImPG/MMLMqjlSRknapVO8u43nnWk=";
      #     };
      #     buildInputs = super.buildInputs ++ [
      #       (webkitgtk_4_1.override {
      #         libsoup = gnome.libsoup;
      #       })
      #     ];
      #     nativeBuildInputs = super.nativeBuildInputs ++ [
      #       autoreconfHook
      #     ];
      #     postPatch = ''
      #       substituteInPlace configure.ac \
      #         --replace "PKG_CHECK_MODULES(LIBSECRET, libsecret-1 >= 0.18)" ""
      #     '';
      #     preAutoreconf = ''
      #       autoupdate
      #     '';
      #     preConfigure = ''
      #       NOCONFIGURE=x ./autogen.sh
      #       touch gtk4/nm-openconnect-dialog.ui
      #     '';
      #   }))
      # ];
    };

    wireless = {
      enable = false;
      iwd.enable = true;
      userControlled.enable = true;
      allowAuxiliaryImperativeNetworks = true;
    };
  };

  hardware.trackpoint = {
    enable = true;
    speed = 500;
    sensitivity = 250;
  };

  powerManagement = let
    modprobe = "${pkgs.kmod}/bin/modprobe";
  in {
    enable = true;

    # This fixes an issue with not being able to suspend or wake up from suspend
    # due to a kernel bug[1].
    #
    # [1]: https://bbs.archlinux.org/viewtopic.php?id=270964
    # [1]: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998
    # [1]: https://bugs.launchpad.net/ubuntu/+source/pm-utils/+bug/562484/comments/3
    # [1]: https://gist.github.com/ioggstream/8f380d398aef989ac455b93b92d42048
    powerDownCommands = "${modprobe} -r xhci_pci";
    powerUpCommands = "${modprobe} xhci_pci";
  };

  services = {
    thinkfan = {
      enable = true;

      settings = {
        sensors = [
          {
            hwmon = "/sys/class/hwmon";
            name = "coretemp";
            indices = [1];
          }
        ];
        fans = [{tpacpi = "/proc/acpi/ibm/fan";}];
        levels = [
          ["level auto" 0 50]
          ["level disengaged" 50 32767]
        ];
      };
    };

    fwupd.enable = true;
  };

  boot = {
    # Speeding up Wi-Fi a bit.
    extraModprobeConfig = ''
      options iwlwifi 11n_disable=1
    '';

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

      luks.devices."root" = {
        device = "/dev/disk/by-uuid/c1b46f24-eec0-47d2-a142-75ddfd7bb218";
        allowDiscards = true;
        bypassWorkqueues = true;
      };
    };

    loader = {
      efi.canTouchEfiVariables = true;

      systemd-boot = {
        enable = true;
        configurationLimit = 10;
      };
    };
  };

  fileSystems = {
    "/boot" = {
      device = "/dev/disk/by-uuid/1083-C8A0";
      fsType = "vfat";
    };

    "/" = {
      device = "/dev/disk/by-uuid/bb8b09dc-cc67-47e5-8280-532b17a9e62a";
      fsType = "xfs";
      options = ["noatime"];
    };
  };

  # NOTE This will make hibernation extremely hard if on an encrypted partition.
  # This also could not work on ZFS or Btrfs.
  swapDevices = [
    {
      device = "/swapfile";
      size = 8 * 1024;
    }
  ];

  zramSwap = {
    enable = true;
    memoryPercent = 25;
  };
}