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;
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 {
@@ -24,14 +22,13 @@ in
description = "Default gateway";
};
};
config = mkIf cfg.enable {
config = let fallback = "1.1.1.1";
in mkIf cfg.enable {
networking = {
defaultGateway = cfg.gateway;
useDHCP = false;
nameservers = [
cfg.dns
"1.1.1.1"
];
nameservers = [ cfg.dns ]
++ lib.lists.optionals (!config.services.resolved.enable) [ fallback ];
interfaces = {
${cfg.interface} = {
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";
ip = "192.168.0.11";
#dns = "127.0.0.1";
dns = "192.168.10";
dns = "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; };
services = { syncthing = { enable = true; }; };
hardware = {