configuration/common/system.nix

127 lines
3.7 KiB
Nix
Raw Normal View History

2021-12-02 19:48:45 +00:00
{ config, lib, pkgs, ... }:
let
2023-01-21 02:59:40 +00:00
inherit (config) host;
2024-01-24 08:53:24 +00:00
inherit (lib) escapeShellArg mkOption removePrefix;
2023-06-16 18:11:55 +00:00
inherit (lib.types) path;
2024-01-24 08:53:24 +00:00
inherit (import ./resources/lib.nix { inherit lib; }) frame;
2023-05-18 01:45:47 +00:00
identity = import ./resources/identity.nix;
2024-05-09 19:18:01 +00:00
palette = import ./resources/palette.nix { inherit lib pkgs; };
2021-12-02 19:48:45 +00:00
in
{
imports = [
2023-12-10 23:17:45 +00:00
./components/applications.system.nix
2023-05-17 18:40:54 +00:00
./components/backup.system.nix
./components/desktop.system.nix
2023-05-17 18:40:54 +00:00
./components/keyboard.system.nix
./components/locale.system.nix
2024-02-19 23:42:48 +00:00
./components/logs.system.nix
2023-05-17 18:40:54 +00:00
./components/mail.system.nix
./components/networking.system.nix
./components/nix.system.nix
./components/openpgp.system.nix
2023-05-17 18:40:54 +00:00
./components/printer.system.nix
./components/scanner.system.nix
./components/users.system.nix
./components/virtualization.system.nix
2023-11-02 04:44:52 +00:00
./components/wireguard.system.nix
2021-12-02 19:48:45 +00:00
];
options.host = {
2023-06-16 18:11:55 +00:00
local = mkOption { type = path; };
resources = mkOption { type = path; };
};
config = {
# Boot
allowedUnfree = [ "memtest86-efi" ];
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.memtest86.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.plymouth.enable = true;
2024-01-24 08:53:24 +00:00
boot.initrd.preDeviceCommands = with palette.ansiFormat; ''
info $'\n'${escapeShellArg (frame magenta ''
${magenta "If found, please contact:"}
${cyan "Name:"} ${identity.name.long}
${cyan "Email:"} ${identity.email}
${cyan "Phone:"} ${identity.phone}
'')}$'\n'
'';
# Swap
zramSwap.enable = true;
# Filesystems
boot.initrd.luks = {
gpgSupport = true;
devices.pv = {
device = "/dev/disk/by-partlabel/pv-enc";
allowDiscards = true;
fallbackToPassword = true;
gpgCard.encryptedPass = ./local/resources/luks-passphrase.gpg;
2023-05-18 01:45:47 +00:00
gpgCard.publicKey = identity.openpgp.asc;
};
2021-12-02 19:48:45 +00:00
};
fileSystems."/".options = [ "compress=zstd:2" "discard=async" "noatime" ];
fileSystems."/boot".options = [ "umask=0077" ];
services.btrfs.autoScrub.enable = true;
2023-06-01 06:03:19 +00:00
boot.tmp.cleanOnBoot = true;
2021-12-02 19:48:45 +00:00
# Console
console.packages = with pkgs; [ terminus_font ];
console.font = "ter-v32n";
2024-04-23 04:58:34 +00:00
console.colors = map (removePrefix "#") (with palette.hex; [
2024-04-23 21:51:29 +00:00
"#000000" red green yellow blue orange purple platinum
2024-04-23 22:14:36 +00:00
white-dim red green yellow blue orange purple white
]);
# Power
systemd.ctrlAltDelUnit = "poweroff.target";
2022-09-08 23:31:57 +00:00
services.irqbalance.enable = true;
2021-12-02 19:48:45 +00:00
# Authentication
security.pam.u2f = {
enable = true;
appId = "pam://${host.name}";
2023-12-01 07:20:01 +00:00
authFile = "/etc/u2f-mappings";
control = "sufficient";
cue = true;
};
2022-04-13 16:36:13 +00:00
# Authorization
security.sudo.extraRules = [
{
groups = [ "wheel" ];
commands = [
{ command = "/run/current-system/sw/bin/btrfs balance start --enqueue -dusage=50 -musage=50 /"; options = [ "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/nix-channel --update"; options = [ "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/nixos-rebuild boot"; options = [ "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/nixos-rebuild switch"; options = [ "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/poweroff"; options = [ "NOPASSWD" ]; }
];
}
];
2021-12-02 19:48:45 +00:00
# SSH
2023-01-13 19:19:41 +00:00
services.openssh = {
enable = true;
2023-06-01 06:03:19 +00:00
settings.PasswordAuthentication = false;
};
2021-12-02 19:48:45 +00:00
# SMART monitoring
services.smartd = {
enable = true;
notifications.mail.enable = true;
};
# Firmware updates
2022-09-08 23:38:41 +00:00
hardware.enableRedistributableFirmware = true;
services.fwupd.enable = true;
2023-12-21 19:56:04 +00:00
# Profiling
services.sysprof.enable = true;
2021-12-02 19:48:45 +00:00
};
}