integrate settings raspberry pi
This commit is contained in:
parent
1683c4caa8
commit
25937f535b
6 changed files with 212 additions and 193 deletions
|
@ -2,6 +2,7 @@
|
|||
imports = [ ./docker_swarm.nix ];
|
||||
|
||||
options.lab.vm = {
|
||||
# TODO: make global.
|
||||
baseMACAddress = lib.mkOption {
|
||||
default = "BA:DB:EE:F0:00:00";
|
||||
type = lib.types.str;
|
||||
|
@ -17,29 +18,6 @@
|
|||
'';
|
||||
};
|
||||
|
||||
staticNetworking = lib.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
Whether this VM has static networking configuration applied.
|
||||
Routing is prepopulated, but IP addresses have to be set.
|
||||
'';
|
||||
};
|
||||
|
||||
staticIPv4 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Static IPv4 address for the VM.
|
||||
'';
|
||||
};
|
||||
|
||||
staticIPv6 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Static IPv6 address for the VM.
|
||||
'';
|
||||
};
|
||||
|
||||
shares = lib.mkOption {
|
||||
default = [ ];
|
||||
description = ''
|
||||
|
@ -73,16 +51,20 @@
|
|||
mountPoint = "/etc/ssh/host_keys";
|
||||
}];
|
||||
|
||||
services.openssh = {
|
||||
# hostKeys = [{
|
||||
# path = "/etc/ssh/host_keys/ssh_host_ed25519_key";
|
||||
# type = "ed25519";
|
||||
# }];
|
||||
services.openssh =
|
||||
let
|
||||
hostKeyPath = "/etc/ssh/host_keys/ssh_host_ed25519_key";
|
||||
in
|
||||
{
|
||||
hostKeys = [{
|
||||
path = hostKeyPath;
|
||||
type = "ed25519";
|
||||
}];
|
||||
|
||||
# extraConfig = ''
|
||||
# HostKey /etc/ssh/host_keys/ssh_host_ed25519_key
|
||||
# '';
|
||||
};
|
||||
extraConfig = ''
|
||||
HostKey ${hostKeyPath}
|
||||
'';
|
||||
};
|
||||
|
||||
microvm = {
|
||||
# TODO: make this dependent on the host CPU
|
||||
|
@ -108,51 +90,5 @@
|
|||
mac = pkgs.lib.net.mac.add config.lab.vm.id config.lab.vm.baseMACAddress;
|
||||
}];
|
||||
};
|
||||
|
||||
networking.useDHCP = false;
|
||||
|
||||
systemd.network =
|
||||
let
|
||||
cfg = config.lab.networking;
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
|
||||
networks = {
|
||||
"30-main-nic" = {
|
||||
matchConfig.Name = "en*";
|
||||
|
||||
networkConfig = {
|
||||
IPv6AcceptRA = ! config.lab.vm.staticNetworking;
|
||||
DHCP = lib.mkIf (! config.lab.vm.staticNetworking) "yes";
|
||||
|
||||
Address = lib.mkIf config.lab.vm.staticNetworking [
|
||||
"${ config.lab.vm.staticIPv4}/${cfg.dmz.ipv4.prefixLength}"
|
||||
"${config.lab.vm.staticIPv6}/${cfg.dmz.ipv6.prefixLength}"
|
||||
];
|
||||
|
||||
DNS = lib.mkIf config.lab.vm.staticNetworking [
|
||||
cfg.dmz.ipv4.router
|
||||
cfg.dmz.ipv6.router
|
||||
];
|
||||
};
|
||||
|
||||
routes = lib.mkIf config.lab.vm.staticNetworking [
|
||||
{
|
||||
routeConfig = {
|
||||
Gateway = cfg.dmz.ipv4.router;
|
||||
Destination = "0.0.0.0/0";
|
||||
};
|
||||
}
|
||||
{
|
||||
routeConfig = {
|
||||
Gateway = cfg.dmz.ipv6.router;
|
||||
Destination = "::/0";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Reference in a new issue