{ config, pkgs, ... }: { ############################################################ # BOOTLOADER – GRUB ############################################################ boot.loader.grub = { enable = true; device = "nodev"; efiSupport = true; efiInstallAsRemovable = true; useOSProber = false; }; boot.loader.efi = { canTouchEfiVariables = false; efiSysMountPoint = "/boot"; }; ############################################################ # INITRD – HARDWARE‑AGNOSTIC + LUKS ############################################################ boot.initrd.availableKernelModules = [ "usb_storage" "xhci_hcd" "ehci_pci" "ahci" "sd_mod" "nvme" "sr_mod" ]; boot.kernelModules = []; boot.initrd.luks.devices.root = { device = "/dev/disk/by-partlabel/nixos-crypt"; preLVM = true; allowDiscards = true; }; ############################################################ # FIRMWARE ############################################################ 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"; }; fileSystems."/boot" = { device = "/dev/disk/by-label/EFI"; fsType = "vfat"; }; ############################################################ # NETWORKING / LOCALE ############################################################ networking.networkmanager.enable = true; time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "de_DE.UTF-8"; console.keyMap = "de"; ############################################################ # BLUETOOTH ############################################################ hardware.bluetooth.enable = true; services.blueman.enable = true; ############################################################ # DESKTOP ############################################################ services.displayManager.gdm.enable = true; services.desktopManager.gnome.enable = true; services.libinput.enable = true; ############################################################ # AUDIO ############################################################ 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; ############################################################ # USER ############################################################ 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 vim curl wget openssh obsidian libreoffice keepassxc thunderbird tor-browser inkscape gimp pdfarranger ]; programs.firefox.enable = true; ############################################################ # PORTABLE USB‑ROOT LOSS → SHUTDOWN ############################################################ systemd.services.shutdown-on-root-usb-loss = { description = "Shutdown if USB device backing / disappears"; wantedBy = [ "multi-user.target" ]; after = [ "local-fs.target" ]; serviceConfig = { Type = "simple"; ExecStart = pkgs.writeShellScript "watch-root-usb" '' set -e ROOT_SRC="$(findmnt -n -o SOURCE / || true)" [ -z "$ROOT_SRC" ] && exit 0 if [[ "$ROOT_SRC" == /dev/dm-* ]]; then PARENT="$(lsblk -no PKNAME "$ROOT_SRC")" ROOT_DEV="/dev/$PARENT" else ROOT_DEV="$ROOT_SRC" fi TRAN="$(lsblk -no TRAN "$ROOT_DEV" || true)" [ "$TRAN" != "usb" ] && exec sleep infinity DEV_NAME="$(basename "$ROOT_DEV")" while [ -e "/sys/class/block/$DEV_NAME" ]; do sleep 1 done systemctl poweroff ''; Restart = "no"; }; }; ############################################################ # KERNEL FAILSAFE ############################################################ boot.kernel.sysctl = { "kernel.panic" = 5; "kernel.panic_on_oops" = 1; }; ############################################################ # GIT AUTO‑UPDATE ############################################################ 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 if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; 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 Git"; script = "/etc/update-nixos-config.sh"; serviceConfig = { Type = "oneshot"; User = "root"; }; }; systemd.timers.nixos-git-update = { wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "60s"; }; }; ############################################################ # SWAP ############################################################ zramSwap.enable = true; ############################################################ # VERSION ############################################################ system.stateVersion = "25.11"; }