summary refs log tree commit diff stats
path: root/system/prefect.nix
blob: e145c304abdfa835843881de9cee47033439a71b (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
202
203
204
205
206
207
208
209
210
211
212
{ config
, pkgs
, ...
}: {
  imports = [
    ./settings/base.nix
    ./settings/configuration/berlin.nix
    ./settings/configuration/british-english.nix
    ./settings/configuration/nix-linux.nix
    ./settings/configuration/user.nix
    ./settings/hardware/audio.nix
    ./settings/hardware/bare-metal.nix
    ./settings/hardware/mouse.nix
    ./settings/hardware/systemd-boot.nix
    ./settings/hardware/nvidia-gpu.nix
    ./settings/hardware/keyboard.nix
    ./settings/hardware/keyboard-lofree.nix
    ./settings/hardware/trezor.nix
    ./settings/services/syncthing.nix
    ./settings/services/virtualisation.nix
    ./settings/user-interface.nix
    ./settings/programs/base.nix
    ./settings/programs/kde.nix
    ./settings/programs/shell.nix
    ./settings/programs/docker.nix
    ./settings/dev.nix
    ./settings/gaming.nix
    <nixos-hardware/common/cpu/amd>
    <nixos-hardware/common/cpu/amd/pstate.nix>
    <nixos-hardware/common/pc/ssd>
    <nixos-hardware/common/pc>
    <nixos-hardware/common/gpu/nvidia>
  ];

  virtualisation.vmVariant = {
    disabledModules = [
      ./settings/hardware/nvidia-gpu.nix
      ./settings/hardware/bare-metal.nix
      ./settings/gaming.nix
      ./settings/user-interface.nix
      ./settings/programs/kde.nix
      <nixos-hardware/common/cpu/amd>
      <nixos-hardware/common/cpu/amd/pstate.nix>
      <nixos-hardware/common/pc/ssd>
      <nixos-hardware/common/pc>
      <nixos-hardware/common/gpu/nvidia>
    ];
    services.qemuGuest.enable = true;
    virtualisation = {
      memorySize = 4096;
      cores = 4;
    };
  };

  nixpkgs.hostPlatform = "x86_64-linux";

  services.xserver.screenSection = ''
    Option "MetaModes" "2560x1440_165 +0+0 { }"
    #Option "MetaModes" "2560x1440_120 +0+0 { AllowGSYNC=Off }"
  '';
  services.xserver.monitorSection = ''
    Option "DPMS"
  '';
  services.displayManager.autoLogin = {
    user = "alan";
    enable = true;
  };

  boot.kernelPackages = pkgs.linuxPackages_xanmod;
  boot.extraModulePackages = with config.boot.kernelPackages; [
    zenpower
  ];

  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];

  boot.initrd.supportedFilesystems = [ "xfs" "ext4" ];
  fileSystems = {
    "/" = {
      device = "/dev/disk/by-partlabel/nixos";
      fsType = "xfs";
      options = [ "lazytime" "nodiscard" ];
    };

    "/boot" = {
      device = "/dev/disk/by-partlabel/efi-boot";
      fsType = "vfat";
    };

    "/home" = {
      device = "/dev/disk/by-partlabel/home";
      fsType = "ext4";
      options = [ "lazytime" "nodiscard" ];
    };

    "/mnt/data" = {
      device = "/dev/disk/by-partlabel/data";
      fsType = "ntfs3";
      options = [ "uid=1000" "gid=100" "x-systemd-automount" "nofail" ];
    };
  };

  swapDevices = [
    {
      label = "swap";
      discardPolicy = "once";
    }
  ];

  services.xserver = {
    xautolock.enable = pkgs.lib.mkForce false;
  };

  services.openssh = {
    enable = true;
    openFirewall = false;
    startWhenNeeded = true;
  };
  systemd.services."ssh-no-sleep@" = {
    bindsTo = [ "sshd@%i.service" ];
    wantedBy = [ "sshd@.service" ];
    serviceConfig.ExecStart = "${pkgs.systemd}/bin/systemd-inhibit --mode block --what sleep --who 'ssh session '%I --why 'session still active' ${pkgs.coreutils}/bin/sleep infinity";
  };

  systemd.network = {
    networks."40-enp7s0" = {
      matchConfig = {
        Name = "enp7s0";
      };
      dhcpV4Config = {
        UseDomains = true;
      };
      dhcpV6Config = {
        UseDomains = true;
      };
      ipv6AcceptRAConfig = {
        UseDomains = true;
      };
      networkConfig = {
        MulticastDNS = true;
      };
    };
  };
  networking = {
    hostName = "prefect";
    useDHCP = false;
    useNetworkd = true;
    interfaces.enp7s0 = {
      useDHCP = true;
    };
    hosts = {
      "fd7a:115c:a1e0::53" = [ "tailscale" "ts" ];
      "::1" = [ "alanpearce.test" "alanpearce.localhost" ];
    };

    nftables = {
      enable = true;
    };
    firewall = {
      extraInputRules = ''
        ip saddr 10.0.0.0/8 accept
        ip6 saddr { fd00::/8, fe80::/10 } accept
      '';
    };
  };

  services.resolved = {
    llmnr = "false";
    dnssec = "true";
  };

  services.tailscale = {
    enable = true;
    extraUpFlags = [
      "--accept-dns=true"
      "--accept-routes=false"
    ];
  };

  system.stateVersion = "23.05";

  security.pki.certificates = [
    ''
      -----BEGIN CERTIFICATE-----
      MIIBozCCAUqgAwIBAgIRAJ1slNK3lsucmYYUbtGRUvswCgYIKoZIzj0EAwIwMDEu
      MCwGA1UEAxMlQ2FkZHkgTG9jYWwgQXV0aG9yaXR5IC0gMjAyNCBFQ0MgUm9vdDAe
      Fw0yNDA2MjYxNTM3MTJaFw0zNDA1MDUxNTM3MTJaMDAxLjAsBgNVBAMTJUNhZGR5
      IExvY2FsIEF1dGhvcml0eSAtIDIwMjQgRUNDIFJvb3QwWTATBgcqhkjOPQIBBggq
      hkjOPQMBBwNCAAR1fc1TOhp9oNy/p40BfUd+E13b1/URwwocuZ5w0SKHTE/t8Hp+
      7Zd9ZTYvQ7WxFfaVxmBCcFMUJsTm7bbYTEvlo0UwQzAOBgNVHQ8BAf8EBAMCAQYw
      EgYDVR0TAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUcnlbpAM2ZCRsiCzdFiM5EjCm
      aoEwCgYIKoZIzj0EAwIDRwAwRAIgcKf3vRiF87G0r2+vgBbyfWo4D2TDQWkSrfek
      Q0f1Q5UCIEmyeqrifbp5JnZqtm3IlGVIEQcUeVygqnV/xW3xCAgT
      -----END CERTIFICATE-----
    ''
  ];

  boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
  nix.settings.trusted-users = [ "root" "nixremote" ];
  services.displayManager.hiddenUsers = [ "nixremote" ];
  users.users.nixremote = {
    shell = "/bin/sh";
    isNormalUser = true;
    home = "/var/lib/nixremote";
    createHome = true;
    openssh.authorizedKeys.keys = [
      "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBxa7lxDu0M4chats/VvpFzjT3ruexKa3J9UC6ASo3bN root@NanoPi.lan"
      "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9of82WBHK8nr8L9RGeieLMfcAWaFCeCkmvYHM9LCuT nanopi"
    ];
  };
}