Files
nixos-production/configuration.nix
2025-12-25 22:01:52 +00:00

255 lines
6.4 KiB
Nix

{ config, pkgs, ... }:
{
############################################################
# BOOTLOADER - SYSTEMD-BOOT
############################################################
boot.loader.systemd-boot.enable = true;
boot.loader.efi = {
canTouchEfiVariables = false;
efiSysMountPoint = "/boot";
};
boot.loader.systemd-boot.configurationLimit = 5;
############################################################
# INITRD - HARDWARE-AGNOSTIC + FRAMEBUFFER FALLBACK + LUKS
############################################################
boot.initrd.availableKernelModules = [
"usb_storage"
"xhci_hcd"
"ehci_pci"
"ahci"
"sd_mod"
"nvme"
"sr_mod"
];
# Explicit graphics fallback for unknown hardware
boot.initrd.kernelModules = [
"i915"
"amdgpu"
"nouveau"
];
boot.kernelModules = [];
boot.kernelParams = [
"i8042.noaux"
"i8042.nomux"
"i8042.nopnp"
];
boot.initrd.luks.devices.root = {
device = "/dev/disk/by-partlabel/nixos-crypt";
preLVM = true;
allowDiscards = true;
};
boot.initrd.systemd.enable = true;
boot.plymouth.enable = true;
############################################################
# FIRMWARE - WIDE HARDWARE SUPPORT
############################################################
hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true;
hardware.cpu.intel.updateMicrocode = true;
hardware.cpu.amd.updateMicrocode = true;
############################################################
# FILESYSTEMS
############################################################
fileSystems."/" = {
device = "/dev/disk/by-label/nixos-root";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/EFI";
fsType = "vfat";
};
############################################################
# NETWORKING / LOCALE
############################################################
networking.networkmanager.enable = true;
console.keyMap = "de";
time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "de_DE.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
############################################################
# BLUETOOTH
############################################################
hardware.bluetooth.enable = true;
services.blueman.enable = true;
############################################################
# DESKTOP - GNOME OR KDE
############################################################
# services.displayManager.gdm.enable = true;
# services.desktopManager.gnome.enable = true;
# services.libinput.enable = true;
services.displayManager.sddm.enable = true;
services.displayManager.sddm.wayland.enable = true;
services.desktopManager.plasma6.enable = true;
############################################################
# AUDIO - PIPEWIRE
############################################################
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
############################################################
# PRINTING
############################################################
services.printing.enable = true;
############################################################
# USERS
############################################################
users.users.user = {
isNormalUser = true;
description = "user";
extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.bash;
initialPassword = "1312";
};
############################################################
# SOFTWARE
############################################################
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
git
curl
wget
openssh
obsidian
libreoffice
keepassxc
thunderbird
tor-browser
inkscape
gimp
pdfarranger
];
programs.firefox.enable = true;
############################################################
# GIT AUTO-UPDATE SCRIPT
############################################################
environment.etc."update-nixos-config.sh".text = ''
#!/run/current-system/sw/bin/bash
set -e
export PATH="/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin"
export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
LOCAL_PATH="/var/lib/nixos-config"
REPO_URL="https://git.skarockoi.de/ska/nixos-production.git"
if [ ! -d "$LOCAL_PATH/.git" ]; then
mkdir -p "$LOCAL_PATH"
chmod 700 "$LOCAL_PATH"
git clone "$REPO_URL" "$LOCAL_PATH"
else
cd "$LOCAL_PATH"
git fetch origin
LOCAL_HEAD=$(git rev-parse HEAD)
REMOTE_HEAD=$(git rev-parse origin/main)
if [ "$LOCAL_HEAD" != "$REMOTE_HEAD" ]; then
git reset --hard origin/main
nixos-rebuild switch -I nixos-config="$LOCAL_PATH/configuration.nix"
fi
fi
'';
environment.etc."update-nixos-config.sh".mode = "0700";
systemd.services.nixos-git-update = {
description = "Update NixOS from public Git config";
script = "/etc/update-nixos-config.sh";
serviceConfig = {
Type = "oneshot";
User = "root";
Group = "root";
TimeoutStartSec = "10min";
Restart = "on-failure";
StandardOutput = "journal";
StandardError = "journal";
};
};
systemd.timers.nixos-git-update = {
description = "Check for config updates at startup";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "60s";
OnUnitActiveSec = "5min";
AccuracySec = "30s";
};
};
############################################################
# USB OPTIMIZATIONS
############################################################
zramSwap.enable = true;
boot.tmp.useTmpfs = true;
services.journald.extraConfig = ''
SystemMaxUse=200M
RuntimeMaxUse=50M
'';
############################################################
# NIXOS VERSION
############################################################
system.stateVersion = "25.11";
}