Newer
Older
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
# A NixOS module which configures a system that is hosted by 100TB.
{ pkgs, lib, config, ... }:
let
cfg = config."100tb".config;
options = {
interface = lib.mkOption
{ type = lib.types.str;
example = lib.literalExample "eno0";
description = "The name of the network interface on which to configure a static address.";
};
publicIPv4 = lib.mkOption
{ type = lib.types.str;
example = lib.literalExample "192.0.2.0";
description = "The IPv4 address to statically assign to `interface`.";
};
prefixLength = lib.mkOption
{ type = lib.types.int;
example = lib.literalExample 24;
description = "The statically configured network's prefix length.";
};
gateway = lib.mkOption
{ type = lib.types.str;
example = lib.literalExample "192.0.2.1";
description = "The statically configured address of the network gateway.";
};
gatewayInterface = lib.mkOption
{ type = lib.types.str;
example = lib.literalExample "eno0";
description = "The name of the network interface for the default route.";
default = cfg.interface;
};
grubDeviceID = lib.mkOption
{ type = lib.types.str;
example = lib.literalExample "wwn-0x5000c500936410b9";
description = "The ID of the disk on which to install grub.";
};
rootPublicKey = lib.mkOption
{ type = lib.types.str;
example = lib.literalExample "ssh-ed25519 AAAA... username@host";
description = "The public key to install for the root user.";
};
};
in {
options =
{ "100tb".config = lib.mkOption
{ type = lib.types.submodule { inherit options; };
description = "Host-specific configuration relevant to a 100TB system.";
};
};
config =
{ boot.loader.timeout = 1;
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/disk/by-id/${cfg.grubDeviceID}";
# Let me in to do subsequent configuration.
networking.firewall.enable = false;
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [
cfg.rootPublicKey
];
# Provide the static network configuration.
networking.dhcpcd.enable = false;
networking.interfaces = {
"${cfg.interface}".ipv4.addresses = [
{ address = cfg.publicIPv4; inherit (cfg) prefixLength; }
];
};
networking.defaultGateway = {
address = cfg.gateway;
interface = cfg.gatewayInterface;
};
networking.nameservers = [
"4.2.2.1"
"8.8.8.8"
];
};
}