Files
nixos-config/hosts/armaros/configuration.nix
T

210 lines
4.9 KiB
Nix

{
config,
pkgs,
pkgs-unstable,
inputs,
configPath,
hostname,
hostTypes,
lib,
...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
inputs.home-manager.nixosModules.default
];
# Bootloader.
boot.loader.grub.enable = lib.mkDefault true;
boot.loader.grub.devices = ["nodev"];
nix.settings.experimental-features = ["nix-command" "flakes"];
# Nix optimizations
nix.optimise.automatic = true;
nix.settings.auto-optimise-store = true;
nix.gc = {
automatic = true;
dates = "weekly";
persistent = true;
options = "--delete-older-than 30d";
};
networking.hostName = "armaros";
# Enable networking
networking.networkmanager.enable = true;
# Virtualisation (since this is a VM)
virtualisation.docker.enable = true;
services.qemuGuest.enable = true;
services.spice-vdagentd.enable = true;
# zram for memory efficiency
zramSwap = {
enable = true;
priority = 100;
memoryPercent = 20; # Lower for lightweight VM
swapDevices = 1;
algorithm = "zstd";
};
# Btrfs auto-scrub
services.btrfs.autoScrub = {
enable = true;
interval = "weekly";
fileSystems = ["/" "/home" "/nix"];
};
# Snapper — automatic btrfs snapshots so you can roll back
services.snapper = {
# Snapshot / every hour, keep 10 hourly and 7 daily
configs.root = {
SUBVOLUME = "/";
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
TIMELINE_MIN_AGE = "1800";
TIMELINE_LIMIT_HOURLY = "10";
TIMELINE_LIMIT_DAILY = "7";
TIMELINE_LIMIT_MONTHLY = "3";
TIMELINE_LIMIT_YEARLY = "0";
};
# Snapshot /home every 4 hours
configs.home = {
SUBVOLUME = "/home";
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
TIMELINE_MIN_AGE = "14400";
TIMELINE_LIMIT_HOURLY = "6";
TIMELINE_LIMIT_DAILY = "14";
TIMELINE_LIMIT_MONTHLY = "3";
TIMELINE_LIMIT_YEARLY = "0";
};
};
# Set your time zone.
time.timeZone = "America/Los_Angeles";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# Enable X11 for lightweight GUI
services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
services.xserver.desktopManager.xfce.enable = true;
# Configure keymap in X11
services.xserver.xkb = {
layout = "us";
variant = "";
};
services.sunshine = {
enable = true;
autoStart = true;
capSysAdmin = true; # Required for KMS screen capture (especially on Wayland)
openFirewall = true; # Automatically opens required ports for Moonlight
};
# Enable Avahi so Moonlight automatically discovers your PC on the network
services.avahi = {
enable = true;
publish.enable = true;
publish.userServices = true;
};
# Enable CUPS to print documents.
services.printing.enable = false;
# Enable sound with pipewire (optional, can be disabled for jumpbox)
hardware.pulseaudio.enable = false;
services.pipewire = {
enable = false; # Disable for lightweight VM
};
# Define a user account.
programs.zsh.enable = true;
users.users.rogueking = {
isNormalUser = true;
description = "rogueking";
extraGroups = ["networkmanager" "wheel"];
shell = pkgs.zsh;
packages = with pkgs; [];
};
# Install firefox for web access.
programs.firefox.enable = true;
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Enable OpenSSH daemon for remote access
services.openssh = {
enable = true;
ports = [22];
settings = {
PasswordAuthentication = true;
AllowUsers = ["rogueking"];
UseDns = true;
X11Forwarding = true; # Enable X11 forwarding for jumpbox
PermitRootLogin = "no";
MaxAuthTries = 8;
};
};
users.users."rogueking".openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINXqriPZVIuduc/J7GS1mD171LL0gIbgEjlImsxedWVX"
];
# Minimal firewall configuration
networking.firewall = {
enable = true;
allowedTCPPorts = [22];
logRefusedConnections = true;
};
# List packages installed in system profile.
environment.systemPackages = with pkgs; [
# GUI tools
firefox
putty
btrfs-progs
];
fonts.packages = with pkgs; [
nerd-fonts.hack
dejavu_fonts
];
home-manager = {
extraSpecialArgs = {
inherit
configPath
inputs
pkgs-unstable
hostname
hostTypes
;
};
users = {
"rogueking" = import ./../../home-manager/home.nix;
};
backupFileExtension = "backup";
};
system.stateVersion = "26.05";
}