tangled
alpha
login
or
join now
diogocastro.net
/
dotfiles
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
add cloud networking options
Diogo
3 months ago
03e6c2f9
dc233f8b
+113
-37
5 changed files
expand all
collapse all
unified
split
.gitignore
hosts
iris
default.nix
networking.nix
modules
nixos
networking
cloud.nix
default.nix
-1
.gitignore
···
1
1
-
hosts/heather/networking.nix
+12
-2
hosts/iris/default.nix
···
1
1
{
2
2
imports = [
3
3
./hardware.nix
4
4
-
./networking.nix
5
4
];
6
5
7
6
sys = {
···
14
13
open-webui.enable = true;
15
14
ipw-rb.enable = true;
16
15
};
17
17
-
networking.tailscale.enable = true;
16
16
+
17
17
+
networking = {
18
18
+
tailscale.enable = true;
19
19
+
20
20
+
cloud = {
21
21
+
interface = "ens3";
22
22
+
ipv4 = "51.75.255.245";
23
23
+
ipv6 = "2001:41d0:305:2100::7785";
24
24
+
gateway4 = "51.75.248.1";
25
25
+
gateway6 = "2001:41d0:305:2100::1";
26
26
+
};
27
27
+
};
18
28
};
19
29
20
30
system.stateVersion = "25.05";
-33
hosts/iris/networking.nix
···
1
1
-
let
2
2
-
mainIf = "ens3";
3
3
-
in
4
4
-
{
5
5
-
networking = {
6
6
-
useDHCP = false;
7
7
-
8
8
-
interfaces.${mainIf} = {
9
9
-
useDHCP = false;
10
10
-
11
11
-
ipv4.addresses = [
12
12
-
{
13
13
-
address = "51.75.255.245";
14
14
-
prefixLength = 32;
15
15
-
}
16
16
-
];
17
17
-
18
18
-
ipv6.addresses = [
19
19
-
{
20
20
-
address = "2001:41d0:305:2100::7785";
21
21
-
prefixLength = 128;
22
22
-
}
23
23
-
];
24
24
-
};
25
25
-
26
26
-
defaultGateway = "51.75.248.1";
27
27
-
28
28
-
defaultGateway6 = {
29
29
-
address = "2001:41d0:305:2100::1";
30
30
-
interface = mainIf;
31
31
-
};
32
32
-
};
33
33
-
}
+99
modules/nixos/networking/cloud.nix
···
1
1
+
{ lib, config, ... }:
2
2
+
let
3
3
+
inherit (lib)
4
4
+
mkForce
5
5
+
mkOption
6
6
+
mkIf
7
7
+
types
8
8
+
;
9
9
+
cfg = config.sys.networking.cloud;
10
10
+
in
11
11
+
{
12
12
+
options.sys.networking.cloud = {
13
13
+
interface = mkOption {
14
14
+
type = types.str;
15
15
+
default = "ens3";
16
16
+
description = "The network interface to configure.";
17
17
+
};
18
18
+
19
19
+
ipv4 = mkOption {
20
20
+
type = types.nullOr types.str;
21
21
+
default = null;
22
22
+
description = "The IPv4 address to assign.";
23
23
+
};
24
24
+
25
25
+
ipv6 = mkOption {
26
26
+
type = types.nullOr types.str;
27
27
+
default = null;
28
28
+
description = "The IPv6 address to assign.";
29
29
+
};
30
30
+
31
31
+
gateway4 = mkOption {
32
32
+
type = types.nullOr types.str;
33
33
+
default = null;
34
34
+
description = "The IPv4 default gateway.";
35
35
+
};
36
36
+
37
37
+
gateway6 = mkOption {
38
38
+
type = types.nullOr types.str;
39
39
+
default = null;
40
40
+
description = "The IPv6 default gateway.";
41
41
+
};
42
42
+
};
43
43
+
44
44
+
config = {
45
45
+
networking = {
46
46
+
# Apply Default Gateways only if they are defined
47
47
+
defaultGateway = mkIf (cfg.gateway4 != null) {
48
48
+
address = cfg.gateway4;
49
49
+
interface = cfg.interface;
50
50
+
};
51
51
+
52
52
+
defaultGateway6 = mkIf (cfg.gateway6 != null) {
53
53
+
address = cfg.gateway6;
54
54
+
interface = cfg.interface;
55
55
+
};
56
56
+
57
57
+
dhcpcd.enable = mkForce false;
58
58
+
useDHCP = mkForce false;
59
59
+
60
60
+
# usePredictableInterfaceNames = mkForce false;
61
61
+
62
62
+
interfaces.${cfg.interface} = {
63
63
+
ipv4 = mkIf (cfg.ipv4 != null) {
64
64
+
addresses = [
65
65
+
{
66
66
+
address = cfg.ipv4;
67
67
+
prefixLength = 32;
68
68
+
}
69
69
+
];
70
70
+
71
71
+
routes = mkIf (cfg.gateway4 != null) [
72
72
+
{
73
73
+
address = cfg.gateway4;
74
74
+
prefixLength = 32;
75
75
+
options.scope = "link";
76
76
+
}
77
77
+
];
78
78
+
};
79
79
+
80
80
+
ipv6 = mkIf (cfg.ipv6 != null) {
81
81
+
addresses = [
82
82
+
{
83
83
+
address = cfg.ipv6;
84
84
+
prefixLength = 128;
85
85
+
}
86
86
+
];
87
87
+
88
88
+
routes = mkIf (cfg.gateway6 != null) [
89
89
+
{
90
90
+
address = cfg.gateway6;
91
91
+
prefixLength = 128;
92
92
+
options.scope = "link";
93
93
+
}
94
94
+
];
95
95
+
};
96
96
+
};
97
97
+
};
98
98
+
};
99
99
+
}
+2
-1
modules/nixos/networking/default.nix
···
1
1
{ lib, config, ... }:
2
2
let
3
3
-
inherit (lib) mkForce mkDefault mkIf;
3
3
+
inherit (lib) mkForce mkDefault;
4
4
in
5
5
{
6
6
imports = [
···
8
8
./firewall.nix
9
9
./openssh.nix
10
10
./tailscale.nix
11
11
+
./cloud.nix
11
12
];
12
13
13
14
networking = {