Initial networking VM
Also general improvements around VMs
This commit is contained in:
35
nixos/modules/network.nix
Normal file
35
nixos/modules/network.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) flatten optional mkIf mkDefault mkMerge;
|
||||
inherit (lib.my) mkOpt' mkBoolOpt';
|
||||
|
||||
cfg = config.my.network;
|
||||
in
|
||||
{
|
||||
options = with lib.types; {
|
||||
my.network = {
|
||||
ipv4 = mkOpt' str null "Internal network IPv4 address.";
|
||||
ipv6 = mkOpt' str null "Internal network IPv6 address.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
networking = {
|
||||
domain = mkDefault "int.nul.ie";
|
||||
useDHCP = false;
|
||||
enableIPv6 = mkDefault true;
|
||||
useNetworkd = mkDefault true;
|
||||
};
|
||||
}
|
||||
|
||||
(mkIf config.my.build.isDevVM {
|
||||
networking.interfaces.eth0.useDHCP = mkDefault true;
|
||||
virtualisation = {
|
||||
forwardPorts = flatten [
|
||||
(optional config.services.openssh.openFirewall { from = "host"; host.port = 2222; guest.port = 22; })
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user