53 lines
1.2 KiB
Nix
Raw Permalink Normal View History

2024-04-20 09:42:06 -04:00
{
config,
pkgs,
lib,
...
}:
2025-01-20 22:35:40 -05:00
let
cfg = config.nmasur.profiles.server;
in
2024-04-20 09:42:06 -04:00
{
2025-01-20 22:35:40 -05:00
options.nmasur.profiles.server.enable = lib.mkEnableOption "server configuration";
config = lib.mkIf cfg.enable {
networking.firewall.allowPing = true;
# Implement a simple fail2ban service for sshd
services.sshguard.enable = true;
# Servers need a bootloader or they won't start
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
2022-12-21 14:18:03 -07:00
# Use power button to sleep instead of poweroff
services.logind.powerKey = "suspend";
services.logind.powerKeyLongPress = "poweroff";
2022-12-21 14:18:03 -07:00
# Prevent wake from keyboard
powerManagement.powerDownCommands = ''
2023-04-01 20:21:26 -04:00
set +e
2023-02-22 23:46:24 -05:00
2023-04-01 20:21:26 -04:00
# Fix for Gigabyte motherboard
# /r/archlinux/comments/y7b97e/my_computer_wakes_up_immediately_after_i_suspend/isu99sr/
2023-06-01 22:54:08 -04:00
# Disable if enabled
if (grep "GPP0.*enabled" /proc/acpi/wakeup >/dev/null); then
echo GPP0 | ${pkgs.doas}/bin/doas tee /proc/acpi/wakeup
fi
2022-12-21 14:18:03 -07:00
2023-04-15 10:11:30 -04:00
sleep 2
2023-04-01 20:21:26 -04:00
set -e
'';
2023-04-02 08:22:28 -04:00
services.udev.extraRules = ''
ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="disabled"
ACTION=="add", SUBSYSTEM=="i2c", ATTR{power/wakeup}="disabled"
'';
2025-01-20 22:35:40 -05:00
2022-12-21 14:18:03 -07:00
};
}