From 4c5ddf223c8cb20fc944dbe0e9c315098c5237ff Mon Sep 17 00:00:00 2001 From: ska Date: Mon, 22 Dec 2025 15:51:45 +0000 Subject: [PATCH] Update configuration.nix --- configuration.nix | 141 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 110 insertions(+), 31 deletions(-) diff --git a/configuration.nix b/configuration.nix index 92bdda7..d480e76 100644 --- a/configuration.nix +++ b/configuration.nix @@ -2,20 +2,24 @@ { ############################################################ - # BOOTLOADER – GRUB + # BOOTLOADER – GRUB ############################################################ - boot.loader.grub.enable = true; - boot.loader.grub.device = "nodev"; - boot.loader.grub.efiSupport = true; - boot.loader.grub.efiInstallAsRemovable = true; - boot.loader.grub.useOSProber = false; + boot.loader.grub = { + enable = true; + device = "nodev"; + efiSupport = true; + efiInstallAsRemovable = true; + useOSProber = false; + }; - boot.loader.efi.canTouchEfiVariables = false; - boot.loader.efi.efiSysMountPoint = "/boot"; + boot.loader.efi = { + canTouchEfiVariables = false; + efiSysMountPoint = "/boot"; + }; ############################################################ - # INITRD – LUKS + # INITRD – HARDWARE‑AGNOSTIC + LUKS ############################################################ boot.initrd.availableKernelModules = [ @@ -28,6 +32,8 @@ "sr_mod" ]; + boot.kernelModules = []; + boot.initrd.luks.devices.root = { device = "/dev/disk/by-partlabel/nixos-crypt"; preLVM = true; @@ -35,16 +41,17 @@ }; ############################################################ - # FIRMWARE + # FIRMWARE – WIDE HARDWARE SUPPORT ############################################################ hardware.enableAllFirmware = true; hardware.enableRedistributableFirmware = true; + hardware.cpu.intel.updateMicrocode = true; hardware.cpu.amd.updateMicrocode = true; ############################################################ - # FILESYSTEMS + # FILESYSTEMS – BASED ON LABELS ############################################################ fileSystems."/" = { @@ -58,16 +65,24 @@ }; ############################################################ - # LOCALE / NETWORK + # NETWORKING ############################################################ networking.networkmanager.enable = true; + time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "de_DE.UTF-8"; console.keyMap = "de"; ############################################################ - # DESKTOP + # BLUETOOTH + ############################################################ + + hardware.bluetooth.enable = true; + services.blueman.enable = true; + + ############################################################ + # DESKTOP – GNOME ############################################################ services.displayManager.gdm.enable = true; @@ -75,11 +90,12 @@ services.libinput.enable = true; ############################################################ - # AUDIO + # AUDIO – PIPEWIRE ############################################################ services.pulseaudio.enable = false; security.rtkit.enable = true; + services.pipewire = { enable = true; alsa.enable = true; @@ -88,11 +104,9 @@ }; ############################################################ - # BLUETOOTH / PRINTING + # PRINTING ############################################################ - hardware.bluetooth.enable = true; - services.blueman.enable = true; services.printing.enable = true; ############################################################ @@ -101,13 +115,14 @@ users.users.user = { isNormalUser = true; + description = "user"; extraGroups = [ "wheel" "networkmanager" ]; shell = pkgs.bash; initialPassword = "1312"; }; ############################################################ - # PACKAGES + # SOFTWARE ############################################################ nixpkgs.config.allowUnfree = true; @@ -118,6 +133,12 @@ curl wget openssh + + gnomeExtensions.apps + gnomeExtensions.window-list + gnomeExtensions.dock-from-dash + gnomeExtensions.places-status-indicator + obsidian libreoffice keepassxc @@ -131,17 +152,73 @@ 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 (FIXED) ############################################################ systemd.services.shutdown-on-root-usb-loss = { - description = "Shutdown if device backing / disappears"; + description = "Shutdown if USB device backing / disappears"; wantedBy = [ "multi-user.target" ]; after = [ "local-fs.target" ]; serviceConfig = { Type = "simple"; - ExecStart = pkgs.writeShellScript "watch-root-device" '' + ExecStart = pkgs.writeShellScript "watch-root-usb" '' set -e FINDMNT=${pkgs.util-linux}/bin/findmnt @@ -150,21 +227,23 @@ SLEEP=${pkgs.coreutils}/bin/sleep SYSTEMCTL=${pkgs.systemd}/bin/systemctl - # Resolve root source ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)" [ -z "$ROOT_SRC" ] && exit 0 - # Walk up to the top-level block device - DEV="$ROOT_SRC" - while PARENT="$($LSBLK -no PKNAME "$DEV" 2>/dev/null)"; [ -n "$PARENT" ]; do - DEV="/dev/$PARENT" - done + if [[ "$ROOT_SRC" == /dev/dm-* ]]; then + PARENT="$($LSBLK -no PKNAME "$ROOT_SRC")" + ROOT_DEV="/dev/$PARENT" + else + ROOT_DEV="$ROOT_SRC" + fi - DEV_NAME="$($BASENAME "$DEV")" + TRAN="$($LSBLK -no TRAN "$ROOT_DEV" || true)" + [ "$TRAN" != "usb" ] && exec $SLEEP infinity + + DEV_NAME="$($BASENAME "$ROOT_DEV")" - # Watch until the block device disappears while [ -e "/sys/class/block/$DEV_NAME" ]; do - $SLEEP 0.5 + $SLEEP 1 done $SYSTEMCTL poweroff @@ -183,13 +262,13 @@ }; ############################################################ - # SWAP + # USB OPTIMIZATIONS ############################################################ zramSwap.enable = true; ############################################################ - # SYSTEM VERSION + # NIXOS VERSION ############################################################ system.stateVersion = "25.11";