summaryrefslogtreecommitdiff
path: root/hosts/omega-relay/disko.nix
blob: 2de694367ebf20db61d9ce9bc82d2aed80e4fbca (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
{ config, lib, ... }:
let
  cfg = config.hosts.omega-relay;
in
{
  options.hosts.omega-relay = with lib; {
    root_device = mkOption {
      type = types.path;
      default = "/dev/sda";
      example = "/dev/sda";
      description = "Root device for disko and grub";
    };

    do_disko = mkOption {
      type = types.bool;
      default = !config.addons.virtualisation.isTestVM;
      description = "Whenever to do disko or not.";
    };
  };
  config = lib.mkIf (cfg.do_disko) ({
    services.btrfs.autoScrub = {
      enable = true;
      interval = "weekly";
    };

    boot.loader.grub.device = cfg.root_device;
    # Workaround
    boot.loader.grub.devices = lib.mkForce [ cfg.root_device ];
    boot.loader.efi.canTouchEfiVariables = false;

    # TODO: Mount points

    # Disko for formatting
    disko.devices = {
      disk = {
        main-disk = {
          device = cfg.root_device;
          type = "disk";
          content = {
            type = "gpt";
            partitions = {
              BOOT = {
                type = "EF02";
                size = "1M";
              };
              ESP = {
                type = "EF00";
                size = "128M";
                content = {
                  type = "filesystem";
                  format = "vfat";
                  mountpoint = "/boot";
                  mountOptions = [ "umask=0077" ];
                };
              };
              root = {
                size = "100%";
                content = {
                  type = "filesystem";
                  format = "btrfs";
                  mountpoint = "/";
                };
              };
            };
          };
        };
      };
    };
  });
}