This commit is contained in:
commit
30ce0dafc2
195 changed files with 8902 additions and 0 deletions
6
services/networking/default.nix
Normal file
6
services/networking/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./service.nix
|
||||
];
|
||||
}
|
||||
17
services/networking/options.nix
Normal file
17
services/networking/options.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.machine = {
|
||||
gateway = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Default network gateway";
|
||||
};
|
||||
|
||||
ipv4 = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Main IPv4 address";
|
||||
};
|
||||
};
|
||||
}
|
||||
32
services/networking/service.nix
Normal file
32
services/networking/service.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ config, lib, hostname, ... }:
|
||||
let
|
||||
inherit (config.machine) ipv4 gateway;
|
||||
in
|
||||
with lib; {
|
||||
networking = {
|
||||
hostName = hostname;
|
||||
networkmanager.enable = mkDefault true;
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowPing = true;
|
||||
};
|
||||
nameservers = [
|
||||
"1.1.1.1"
|
||||
"1.0.0.1"
|
||||
"9.9.9.9"
|
||||
"8.8.8.8"
|
||||
];
|
||||
interfaces.ens3 = mkIf (ipv4 != null) {
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = ipv4;
|
||||
prefixLength = 32;
|
||||
}
|
||||
];
|
||||
};
|
||||
defaultGateway = mkIf (gateway != null) {
|
||||
address = gateway;
|
||||
interface = "ens3";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue