all: add module config.nodeconfig.is-server

This commit is contained in:
Adithya 2024-10-22 22:13:53 +05:30
parent 2fccc35829
commit 81a8c582e7
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
9 changed files with 68 additions and 19 deletions

View file

@ -10,6 +10,7 @@ _: {
nodeconfig = { nodeconfig = {
minimize = true; minimize = true;
nix.auto-gc = true; nix.auto-gc = true;
is-server = true;
}; };
environment.sessionVariables = { environment.sessionVariables = {

View file

@ -12,6 +12,7 @@ _: {
minimize = true; minimize = true;
nix.auto-gc = true; nix.auto-gc = true;
is-pi = true; is-pi = true;
is-server = true;
}; };
i18n = { i18n = {

View file

@ -12,6 +12,7 @@ _: {
minimize = true; minimize = true;
nix.auto-gc = true; nix.auto-gc = true;
is-pi = true; is-pi = true;
is-server = true;
}; };
i18n = { i18n = {

View file

@ -12,6 +12,7 @@ _: {
minimize = true; minimize = true;
nix.auto-gc = true; nix.auto-gc = true;
is-pi = true; is-pi = true;
is-server = true;
}; };
i18n = { i18n = {

View file

@ -2,25 +2,28 @@ _: {
networking = { networking = {
useNetworkd = true; useNetworkd = true;
}; };
systemd.network = { systemd = {
enable = true; network = {
networks = { enable = true;
"41-ether" = { wait-online.enable = false;
enable = true; networks = {
matchConfig = { "41-ether" = {
Type = "ether"; enable = true;
}; matchConfig = {
networkConfig = { Type = "ether";
DHCP = "yes"; };
}; networkConfig = {
dhcpV4Config = { DHCP = "yes";
UseDomains = true; };
}; dhcpV4Config = {
ipv6AcceptRAConfig = { UseDomains = true;
UseDomains = true; };
}; ipv6AcceptRAConfig = {
linkConfig = { UseDomains = true;
RequiredForOnline = "yes"; };
linkConfig = {
RequiredForOnline = "yes";
};
}; };
}; };
}; };

View file

@ -10,6 +10,7 @@ _: {
nodeconfig = { nodeconfig = {
minimize = true; minimize = true;
nix.auto-gc = true; nix.auto-gc = true;
is-server = true;
}; };
environment.sessionVariables = { environment.sessionVariables = {

View file

@ -3,6 +3,7 @@ _: {
./general.nix ./general.nix
./nix.nix ./nix.nix
./pi.nix ./pi.nix
./server.nix
./wireguard.nix ./wireguard.nix
]; ];
} }

View file

@ -18,6 +18,7 @@ let cfg = config.nodeconfig; in {
nixos.enable = lib.mkDefault false; nixos.enable = lib.mkDefault false;
}; };
fonts.fontconfig.enable = lib.mkDefault false;
programs.command-not-found.enable = lib.mkDefault false; programs.command-not-found.enable = lib.mkDefault false;
xdg = { xdg = {
@ -25,6 +26,7 @@ let cfg = config.nodeconfig; in {
icons.enable = lib.mkDefault false; icons.enable = lib.mkDefault false;
mime.enable = lib.mkDefault false; mime.enable = lib.mkDefault false;
sounds.enable = lib.mkDefault false; sounds.enable = lib.mkDefault false;
menus.enable = lib.mkDefault false;
}; };
}; };
} }

38
modules/server.nix Normal file
View file

@ -0,0 +1,38 @@
{ lib, config, ... }:
let cfg = config.nodeconfig; in {
options.nodeconfig = {
is-server = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "configure node as a server";
};
};
config = lib.mkIf cfg.is-server {
boot.kernel.sysctl = {
"net.core.default_qdisc" = "fq";
"net.ipv4.tcp_congestion_control" = "bbr";
};
networking.firewall = {
allowPing = true;
logRefusedConnections = lib.mkDefault false;
};
systemd = {
services = {
NetworkManager-wait-online.enable = false;
systemd-networkd.stopIfChanged = false;
systemd-resolved.stopIfChanged = false;
};
enableEmergencyMode = false;
watchdog = {
runtimeTime = "15s";
rebootTime = "30s";
kexecTime = "1m";
};
sleep.extraConfig = ''
AllowSuspend=no
AllowHibernation=no
'';
};
};
}