Update configuration.nix

This commit is contained in:
ska
2025-12-22 15:51:45 +00:00
parent 97187bbbfb
commit 4c5ddf223c

View File

@@ -5,17 +5,21 @@
# BOOTLOADER GRUB # BOOTLOADER GRUB
############################################################ ############################################################
boot.loader.grub.enable = true; boot.loader.grub = {
boot.loader.grub.device = "nodev"; enable = true;
boot.loader.grub.efiSupport = true; device = "nodev";
boot.loader.grub.efiInstallAsRemovable = true; efiSupport = true;
boot.loader.grub.useOSProber = false; efiInstallAsRemovable = true;
useOSProber = false;
};
boot.loader.efi.canTouchEfiVariables = false; boot.loader.efi = {
boot.loader.efi.efiSysMountPoint = "/boot"; canTouchEfiVariables = false;
efiSysMountPoint = "/boot";
};
############################################################ ############################################################
# INITRD LUKS # INITRD HARDWAREAGNOSTIC + LUKS
############################################################ ############################################################
boot.initrd.availableKernelModules = [ boot.initrd.availableKernelModules = [
@@ -28,6 +32,8 @@
"sr_mod" "sr_mod"
]; ];
boot.kernelModules = [];
boot.initrd.luks.devices.root = { boot.initrd.luks.devices.root = {
device = "/dev/disk/by-partlabel/nixos-crypt"; device = "/dev/disk/by-partlabel/nixos-crypt";
preLVM = true; preLVM = true;
@@ -35,16 +41,17 @@
}; };
############################################################ ############################################################
# FIRMWARE # FIRMWARE WIDE HARDWARE SUPPORT
############################################################ ############################################################
hardware.enableAllFirmware = true; hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true; hardware.enableRedistributableFirmware = true;
hardware.cpu.intel.updateMicrocode = true; hardware.cpu.intel.updateMicrocode = true;
hardware.cpu.amd.updateMicrocode = true; hardware.cpu.amd.updateMicrocode = true;
############################################################ ############################################################
# FILESYSTEMS # FILESYSTEMS BASED ON LABELS
############################################################ ############################################################
fileSystems."/" = { fileSystems."/" = {
@@ -58,16 +65,24 @@
}; };
############################################################ ############################################################
# LOCALE / NETWORK # NETWORKING
############################################################ ############################################################
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
time.timeZone = "Europe/Berlin"; time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "de_DE.UTF-8"; i18n.defaultLocale = "de_DE.UTF-8";
console.keyMap = "de"; console.keyMap = "de";
############################################################ ############################################################
# DESKTOP # BLUETOOTH
############################################################
hardware.bluetooth.enable = true;
services.blueman.enable = true;
############################################################
# DESKTOP GNOME
############################################################ ############################################################
services.displayManager.gdm.enable = true; services.displayManager.gdm.enable = true;
@@ -75,11 +90,12 @@
services.libinput.enable = true; services.libinput.enable = true;
############################################################ ############################################################
# AUDIO # AUDIO PIPEWIRE
############################################################ ############################################################
services.pulseaudio.enable = false; services.pulseaudio.enable = false;
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
enable = true; enable = true;
alsa.enable = true; alsa.enable = true;
@@ -88,11 +104,9 @@
}; };
############################################################ ############################################################
# BLUETOOTH / PRINTING # PRINTING
############################################################ ############################################################
hardware.bluetooth.enable = true;
services.blueman.enable = true;
services.printing.enable = true; services.printing.enable = true;
############################################################ ############################################################
@@ -101,13 +115,14 @@
users.users.user = { users.users.user = {
isNormalUser = true; isNormalUser = true;
description = "user";
extraGroups = [ "wheel" "networkmanager" ]; extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.bash; shell = pkgs.bash;
initialPassword = "1312"; initialPassword = "1312";
}; };
############################################################ ############################################################
# PACKAGES # SOFTWARE
############################################################ ############################################################
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@@ -118,6 +133,12 @@
curl curl
wget wget
openssh openssh
gnomeExtensions.apps
gnomeExtensions.window-list
gnomeExtensions.dock-from-dash
gnomeExtensions.places-status-indicator
obsidian obsidian
libreoffice libreoffice
keepassxc keepassxc
@@ -130,18 +151,74 @@
programs.firefox.enable = true; programs.firefox.enable = true;
############################################################
# GIT AUTOUPDATE 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) # USB ROOT LOSS → SHUTDOWN (FIXED)
############################################################ ############################################################
systemd.services.shutdown-on-root-usb-loss = { systemd.services.shutdown-on-root-usb-loss = {
description = "Shutdown if device backing / disappears"; description = "Shutdown if USB device backing / disappears";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "local-fs.target" ]; after = [ "local-fs.target" ];
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
ExecStart = pkgs.writeShellScript "watch-root-device" '' ExecStart = pkgs.writeShellScript "watch-root-usb" ''
set -e set -e
FINDMNT=${pkgs.util-linux}/bin/findmnt FINDMNT=${pkgs.util-linux}/bin/findmnt
@@ -150,21 +227,23 @@
SLEEP=${pkgs.coreutils}/bin/sleep SLEEP=${pkgs.coreutils}/bin/sleep
SYSTEMCTL=${pkgs.systemd}/bin/systemctl SYSTEMCTL=${pkgs.systemd}/bin/systemctl
# Resolve root source
ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)" ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)"
[ -z "$ROOT_SRC" ] && exit 0 [ -z "$ROOT_SRC" ] && exit 0
# Walk up to the top-level block device if [[ "$ROOT_SRC" == /dev/dm-* ]]; then
DEV="$ROOT_SRC" PARENT="$($LSBLK -no PKNAME "$ROOT_SRC")"
while PARENT="$($LSBLK -no PKNAME "$DEV" 2>/dev/null)"; [ -n "$PARENT" ]; do ROOT_DEV="/dev/$PARENT"
DEV="/dev/$PARENT" else
done 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 while [ -e "/sys/class/block/$DEV_NAME" ]; do
$SLEEP 0.5 $SLEEP 1
done done
$SYSTEMCTL poweroff $SYSTEMCTL poweroff
@@ -183,13 +262,13 @@
}; };
############################################################ ############################################################
# SWAP # USB OPTIMIZATIONS
############################################################ ############################################################
zramSwap.enable = true; zramSwap.enable = true;
############################################################ ############################################################
# SYSTEM VERSION # NIXOS VERSION
############################################################ ############################################################
system.stateVersion = "25.11"; system.stateVersion = "25.11";