format all
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let cfg = config.custom.static-ip;
|
||||
in {
|
||||
let
|
||||
cfg = config.custom.static-ip;
|
||||
in
|
||||
{
|
||||
options.custom.static-ip = {
|
||||
enable = mkEnableOption "Enables static-ip";
|
||||
ip = lib.mkOption {
|
||||
@@ -23,20 +25,23 @@ in {
|
||||
};
|
||||
};
|
||||
config =
|
||||
let fallback = "1.1.1.1";
|
||||
in mkIf cfg.enable {
|
||||
let
|
||||
fallback = "1.1.1.1";
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
networking = {
|
||||
defaultGateway = cfg.gateway;
|
||||
useDHCP = false;
|
||||
nameservers = [ cfg.dns ]
|
||||
++ lib.lists.optionals (!config.services.resolved.enable) [ fallback ];
|
||||
nameservers = [ cfg.dns ] ++ lib.lists.optionals (!config.services.resolved.enable) [ fallback ];
|
||||
interfaces = {
|
||||
${cfg.interface} = {
|
||||
name = "eth0";
|
||||
ipv4.addresses = [{
|
||||
address = cfg.ip;
|
||||
prefixLength = 24;
|
||||
}];
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = cfg.ip;
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user