add headless & server profiles

This commit is contained in:
blahai 2025-02-18 21:17:09 +02:00
parent 53dc5a9eba
commit 4bfaa821c0
Signed by: blahai
SSH key fingerprint: SHA256:ZfCryi+V64yG+vC1ZIIsqgvBCmA31tTi7RJ6M8CvpRc
8 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,10 @@
{
imports = [
./documentation.nix
./environment.nix
./fonts.nix
./services.nix
./systemd.nix
./xdg.nix
];
}

View file

@ -0,0 +1,18 @@
{lib, ...}: let
inherit (lib.modules) mkForce;
inherit (lib.attrsets) mapAttrs;
in {
documentation = mapAttrs (_: mkForce) {
enable = false;
dev.enable = false;
doc.enable = false;
info.enable = false;
nixos.enable = false;
man = {
enable = false;
generateCaches = false;
man-db.enable = false;
mandoc.enable = false;
};
};
}

View file

@ -0,0 +1,4 @@
{
# print the URL instead on servers
environment.variables.BROWSER = "echo";
}

View file

@ -0,0 +1,12 @@
{lib, ...}: let
inherit (lib.modules) mkForce;
inherit (lib.attrsets) mapAttrs;
in {
# we don't need fonts on a server
# since there are no fonts to be configured outside the console
fonts = mapAttrs (_: mkForce) {
packages = [];
fontDir.enable = false;
fontconfig.enable = false;
};
}

View file

@ -0,0 +1,5 @@
{lib, ...}: {
# a headless system should not mount any removable media
# without explicit user action
services.udisks2.enable = lib.modules.mkForce false;
}

View file

@ -0,0 +1,29 @@
{
# https://github.com/numtide/srvos/blob/main/nixos/server/default.nix
systemd = {
# given that our systems are headless, emergency mode is useless.
# we prefer the system to attempt to continue booting so
# that we can hopefully still access it remotely.
enableEmergencyMode = false;
# For more detail, see:
# https://0pointer.de/blog/projects/watchdog.html
watchdog = {
# systemd will send a signal to the hardware watchdog at half
# the interval defined here, so every 10s.
# If the hardware watchdog does not get a signal for 20s,
# it will forcefully reboot the system.
runtimeTime = "20s";
# Forcefully reboot if the final stage of the reboot
# hangs without progress for more than 30s.
# For more info, see:
# https://utcc.utoronto.ca/~cks/space/blog/linux/SystemdShutdownWatchdog
rebootTime = "30s";
};
sleep.extraConfig = ''
AllowSuspend=no
AllowHibernation=no
'';
};
}

View file

@ -0,0 +1,12 @@
{lib, ...}: let
inherit (lib.attrsets) mapAttrs;
inherit (lib.modules) mkForce;
in {
xdg = mapAttrs (_: mkForce) {
sounds.enable = false;
mime.enable = false;
menus.enable = false;
icons.enable = false;
autostart.enable = false;
};
}

View file

@ -0,0 +1,5 @@
{lib, ...}: let
inherit (lib.modules) mkForce;
in {
time.timeZone = mkForce "UTC";
}