This commit is contained in:
Kopatz
2025-02-18 23:59:13 +01:00
parent 32e8a7af77
commit 3b0c8bcfcc
2 changed files with 45 additions and 48 deletions

View File

@@ -1,9 +1,7 @@
{ config, lib, ... }: { config, lib, ... }:
with lib; with lib;
let let cfg = config.custom.static-ip;
cfg = config.custom.static-ip; in {
in
{
options.custom.static-ip = { options.custom.static-ip = {
enable = mkEnableOption "Enables static-ip"; enable = mkEnableOption "Enables static-ip";
ip = lib.mkOption { ip = lib.mkOption {
@@ -24,14 +22,13 @@ in
description = "Default gateway"; description = "Default gateway";
}; };
}; };
config = mkIf cfg.enable { config = let fallback = "1.1.1.1";
in mkIf cfg.enable {
networking = { networking = {
defaultGateway = cfg.gateway; defaultGateway = cfg.gateway;
useDHCP = false; useDHCP = false;
nameservers = [ nameservers = [ cfg.dns ]
cfg.dns ++ lib.lists.optionals (!config.services.resolved.enable) [ fallback ];
"1.1.1.1"
];
interfaces = { interfaces = {
${cfg.interface} = { ${cfg.interface} = {
name = "eth0"; name = "eth0";
@@ -42,5 +39,10 @@ in
}; };
}; };
}; };
services.resolved = lib.mkIf config.services.resolved.enable {
llmnr = "false";
fallbackDns = [ "1.1.1.1" ];
};
}; };
} }

View File

@@ -31,14 +31,9 @@
interface = "enp42s0"; interface = "enp42s0";
ip = "192.168.0.11"; ip = "192.168.0.11";
#dns = "127.0.0.1"; #dns = "127.0.0.1";
dns = "192.168.10"; dns = "192.168.0.10";
#gateway = "192.168.0.10"; #gateway = "192.168.0.10";
}; };
# It uses 1.1.1.1 for some reason? set in /etc/dnsmasq-resolv.conf. no idea why
#services.dnsmasq = {
# enable = true;
# server = [ "192.168.0.10" ];
#};
misc = { docker.enable = true; }; misc = { docker.enable = true; };
services = { syncthing = { enable = true; }; }; services = { syncthing = { enable = true; }; };
hardware = { hardware = {