Skip to content

Commit

Permalink
all: add module config.nodeconfig.is-server
Browse files Browse the repository at this point in the history
  • Loading branch information
adtya committed Oct 22, 2024
1 parent 2fccc35 commit 81a8c58
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 19 deletions.
1 change: 1 addition & 0 deletions hosts/layne/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _: {
nodeconfig = {
minimize = true;
nix.auto-gc = true;
is-server = true;
};

environment.sessionVariables = {
Expand Down
1 change: 1 addition & 0 deletions hosts/rico0/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ _: {
minimize = true;
nix.auto-gc = true;
is-pi = true;
is-server = true;
};

i18n = {
Expand Down
1 change: 1 addition & 0 deletions hosts/rico1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ _: {
minimize = true;
nix.auto-gc = true;
is-pi = true;
is-server = true;
};

i18n = {
Expand Down
1 change: 1 addition & 0 deletions hosts/rico2/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ _: {
minimize = true;
nix.auto-gc = true;
is-pi = true;
is-server = true;
};

i18n = {
Expand Down
41 changes: 22 additions & 19 deletions hosts/shared/networkd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ _: {
networking = {
useNetworkd = true;
};
systemd.network = {
enable = true;
networks = {
"41-ether" = {
enable = true;
matchConfig = {
Type = "ether";
};
networkConfig = {
DHCP = "yes";
};
dhcpV4Config = {
UseDomains = true;
};
ipv6AcceptRAConfig = {
UseDomains = true;
};
linkConfig = {
RequiredForOnline = "yes";
systemd = {
network = {
enable = true;
wait-online.enable = false;
networks = {
"41-ether" = {
enable = true;
matchConfig = {
Type = "ether";
};
networkConfig = {
DHCP = "yes";
};
dhcpV4Config = {
UseDomains = true;
};
ipv6AcceptRAConfig = {
UseDomains = true;
};
linkConfig = {
RequiredForOnline = "yes";
};
};
};
};
Expand Down
1 change: 1 addition & 0 deletions hosts/wynne/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _: {
nodeconfig = {
minimize = true;
nix.auto-gc = true;
is-server = true;
};

environment.sessionVariables = {
Expand Down
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ _: {
./general.nix
./nix.nix
./pi.nix
./server.nix
./wireguard.nix
];
}
2 changes: 2 additions & 0 deletions modules/general.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ let cfg = config.nodeconfig; in {
nixos.enable = lib.mkDefault false;
};

fonts.fontconfig.enable = lib.mkDefault false;
programs.command-not-found.enable = lib.mkDefault false;

xdg = {
autostart.enable = lib.mkDefault false;
icons.enable = lib.mkDefault false;
mime.enable = lib.mkDefault false;
sounds.enable = lib.mkDefault false;
menus.enable = lib.mkDefault false;
};
};
}
38 changes: 38 additions & 0 deletions modules/server.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
};
}

0 comments on commit 81a8c58

Please sign in to comment.