@@ -12,6 +12,8 @@ nixpkgs.lib.nixosSystem {
12
12
13
13
( { config , lib , pkgs , ... } :
14
14
let
15
+ inherit ( self . lib ) hypervisors ;
16
+
15
17
hypervisorMacAddrs = builtins . listToAttrs (
16
18
map ( hypervisor :
17
19
let
@@ -21,7 +23,16 @@ nixpkgs.lib.nixosSystem {
21
23
in {
22
24
name = hypervisor ;
23
25
value = mac ;
24
- } ) self . lib . hypervisors ) ;
26
+ } ) hypervisors
27
+ ) ;
28
+
29
+ hypervisorIPv4Addrs = builtins . listToAttrs (
30
+ lib . imap0 ( i : hypervisor : {
31
+ name = hypervisor ;
32
+ value = "10.0.0.${ toString ( 2 + i ) } " ;
33
+ } ) hypervisors
34
+ ) ;
35
+
25
36
in {
26
37
networking . hostName = "microvms-host" ;
27
38
system . stateVersion = config . system . nixos . version ;
@@ -98,9 +109,9 @@ nixpkgs.lib.nixosSystem {
98
109
dhcpServerStaticLeases = lib . imap0 ( i : hypervisor : {
99
110
dhcpServerStaticLeaseConfig = {
100
111
MACAddress = hypervisorMacAddrs . ${ hypervisor } ;
101
- Address = "10.0.0. ${ toString ( 2 + i ) } " ;
112
+ Address = hypervisorIPv4Addrs . ${ hypervisor } ;
102
113
} ;
103
- } ) ( builtins . attrNames hypervisorMacAddrs ) ;
114
+ } ) hypervisors ;
104
115
# IPv6 SLAAC
105
116
ipv6Prefixes = [ {
106
117
ipv6PrefixConfig . Prefix = "fd12:3456:789a::/64" ;
@@ -119,6 +130,10 @@ nixpkgs.lib.nixosSystem {
119
130
enableIPv6 = true ;
120
131
internalInterfaces = [ "virbr0" ] ;
121
132
} ;
133
+
134
+ networking . extraHosts = lib . concatMapStrings ( hypervisor : ''
135
+ ${ hypervisorIPv4Addrs . ${ hypervisor } } ${ hypervisor }
136
+ '' ) hypervisors ;
122
137
} )
123
138
] ;
124
139
}
0 commit comments