summaryrefslogtreecommitdiff
path: root/hosts/minime/zfs.nix
blob: 826363c2e4f40013800d6bb6447285535d4b6a6c (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
{
  pkgs,
  ...
}:
{
  services.fstrim.enable = true;
  services.zfs = {
    trim.enable = true;
    autoScrub = {
      enable = true;
      pools = [ "zpool" ];
      interval = "weekly";
      randomizedDelaySec = "6h";
    };
  };
  networking.hostId = "41ba28ff";
  boot = {
    zfs.forceImportRoot = false;
    plymouth.enable = false;
    tmp.useTmpfs = true;
  };

  # unlock over ssh
  boot.initrd.network = {
    enable = true;
    ssh = {
      enable = true;
      port = 2222;
      hostKeys = [ /etc/secrets/initrd/ssh_host_rsa_key ];
      authorizedKeys = [
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJl9iYG5oHBq/poBn7Jf1/FGWWbAnbx+NKjs7qtT3uAK 0xa@toaster 2024-12-31"
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAXrwZsBChUhVuF5gFEfj8GwQlnrqEttAytS5jVCfuE4 0xa@frituurpan"
      ];
    };
  };

  boot.initrd.systemd.services.zfs-setup-root-profile = {
    wantedBy = [ "initrd.target" ];
    before = [ "initrd-root-fs.target" ];
    unitConfig.DefaultDependencies = false;
    script = ''
      mkdir -p /var/empty
      echo "systemd-tty-ask-password-agent --watch" > /var/empty/.profile
    '';
    serviceConfig.Type = "oneshot";
  };
  # support for network
  boot.initrd.kernelModules = [
    "igc"
    "i40e"
    "mt7921e"
  ];
  boot.kernelModules = [
    "igc"
    "i40e"
    "mt7921e"
  ];

}