summaryrefslogtreecommitdiff
path: root/hosts/laptop/configuration.nix
blob: 0c87cfe7743dcd3a38b6494f27cdbbcb6c493e5f (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
{
  config,
  lib,
  pkgs,
  inputs,
  ...
}:

{
  imports = [
    # Include the results of the hardware scan.
    ./hardware-configuration.nix
    ../../modules/common.nix
    ../../modules/re.nix
  ];

  boot.loader.grub = {
    enable = true;
    device = "nodev";
    efiSupport = true;
  };
  boot.loader.efi.canTouchEfiVariables = false;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";

  networking.hostName = "laptop";
  networking.wireless.iwd.enable = true;
  networking.wireless.iwd.settings = {
    General.EnableNetworkConfiguration = true;
  };
  networking.nameservers = [
    "1.1.1.1"
    "8.8.8.8"
  ];

  programs.light.enable = true;

  programs.bash.shellAliases = {
    battery = "echo $(($(cat /sys/class/power_supply/BAT0/charge_now)*100/$(cat /sys/class/power_supply/BAT0/charge_full)))%";
    hibernate = "systemctl hibernate";
    vpn-up = "sudo systemctl start wg-quick-wg0";
    vpn-down = "sudo systemctl stop wg-quick-wg0";
  };

  programs.fish.shellAliases = {
    battery = "echo (math (cat /sys/class/power_supply/BAT0/charge_now) * 100 / (cat /sys/class/power_supply/BAT0/charge_full))%";
    hibernate = "systemctl hibernate";
    vpn-up = "sudo systemctl start wg-quick-wg0";
    vpn-down = "sudo systemctl stop wg-quick-wg0";
  };

  services.logind = {
    powerKey = "ignore";
    powerKeyLongPress = "ignore";
  };

  services.keyd = {
    enable = true;
    keyboards.default = {
      ids = [ "*" ];
      settings.main.capslock = "overload(control, esc)";
    };
  };

  home-manager.users.christian.custom.xmobarBattery = true;
  home-manager.users.christian.custom.xmobarVpn = true;

  # WireGuard — not started on boot, use `wg-quick up wg0` / `wg-quick down wg0`
  # Private key must be placed at /etc/wireguard/wg0.key (mode 600, owned by root)
  networking.wg-quick.interfaces.wg0 = {
    autostart = false;
    address = [ "10.67.40.2/32" ];
    privateKeyFile = "/etc/wireguard/wg0.key";
    peers = [
      {
        publicKey = "wg37lctIxY4qbcyjVDrEI4mahH2Bhgv+73djEjJSyww=";
        endpoint = "vpn.soltermann.xyz:51820";
        allowedIPs = [ "10.67.40.0/24" ];
        persistentKeepalive = 25;
      }
    ];
  };

  swapDevices = [
    {
      device = "/swapfile";
      size = 8192; # 8GB in MiB
    }
  ];

  boot.resumeDevice = "/dev/disk/by-uuid/56ae0488-d952-41d8-8128-60a46e979d91";
  boot.kernelParams = [ "resume_offset=12832768" ];

  system.stateVersion = "25.11";
}