{ 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 – WIDE HARDWARE SUPPORT ############################################################ hardware.enableAllFirmware = true; hardware.enableRedistributableFirmware = true; hardware.cpu.intel.updateMicrocode = true; hardware.cpu.amd.updateMicrocode = true; ############################################################ # FILESYSTEMS – BASED ON LABELS ############################################################ fileSystems."/" = { device = "/dev/disk/by-label/nixos-root"; fsType = "ext4"; }; fileSystems."/boot" = { device = "/dev/disk/by-label/EFI"; fsType = "vfat"; }; ############################################################ # NETWORKING ############################################################ 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 – GNOME ############################################################ services.displayManager.gdm.enable = true; services.desktopManager.gnome.enable = true; services.libinput.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; ############################################################ # 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 gnomeExtensions.apps gnomeExtensions.window-list gnomeExtensions.dock-from-dash gnomeExtensions.places-status-indicator 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 # Ensure all system tools are available 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" echo "Cloning config from $REPO_URL..." git clone "$REPO_URL" "$LOCAL_PATH" else cd "$LOCAL_PATH" echo "Fetching updates..." git fetch origin LOCAL_HEAD=$(git rev-parse HEAD) REMOTE_HEAD=$(git rev-parse origin/main) if [ "$LOCAL_HEAD" != "$REMOTE_HEAD" ]; then echo "New config available. Updating..." git reset --hard origin/main nixos-rebuild switch -I nixos-config="$LOCAL_PATH/configuration.nix" echo "System updated successfully." else echo "Config is already up to date." 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"; }; }; systemd.timers.nixos-git-update = { description = "Check for config updates hourly"; wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "60s"; }; }; ############################################################ # USB ROOT LOSS → SHUTDOWN (CORRECTED) ############################################################ systemd.services.shutdown-on-root-usb-loss = { description = "Shutdown if device backing / disappears"; wantedBy = [ "multi-user.target" ]; after = [ "local-fs.target" ]; serviceConfig = { Type = "simple"; Restart = "always"; RestartSec = "1"; ExecStart = pkgs.writeShellScript "watch-root-device" '' set -e FINDMNT=${pkgs.util-linux}/bin/findmnt LSBLK=${pkgs.util-linux}/bin/lsblk BASENAME=${pkgs.coreutils}/bin/basename SLEEP=${pkgs.coreutils}/bin/sleep SYSTEMCTL=${pkgs.systemd}/bin/systemctl # Wait until root is visible while true; do ROOT_SRC="$($FINDMNT -n -o SOURCE / 2>/dev/null || true)" [ -n "$ROOT_SRC" ] && break $SLEEP 1 done # Resolve to top-level block device PARENT="$($LSBLK -ndo PKNAME "$ROOT_SRC" 2>/dev/null || true)" if [ -n "$PARENT" ]; then ROOT_DEV="/dev/$PARENT" else ROOT_DEV="$ROOT_SRC" fi DEV_NAME="$($BASENAME "$ROOT_DEV")" # Wait until sysfs entry exists while [ ! -e "/sys/class/block/$DEV_NAME" ]; do $SLEEP 1 done # Watch until device disappears while [ -e "/sys/class/block/$DEV_NAME" ]; do $SLEEP 0.5 done $SYSTEMCTL poweroff ''; }; }; ############################################################ # KERNEL FAILSAFE ############################################################ boot.kernel.sysctl = { "kernel.panic" = 5; "kernel.panic_on_oops" = 1; }; ############################################################ # USB OPTIMIZATIONS ############################################################ zramSwap.enable = true; ############################################################ # NIXOS VERSION ############################################################ system.stateVersion = "25.11"; }