Update configuration.nix

This commit is contained in:
ska
2025-12-22 15:41:04 +00:00
parent e9842c73cb
commit 546fdca607

View File

@@ -5,21 +5,17 @@
# BOOTLOADER GRUB # BOOTLOADER GRUB
############################################################ ############################################################
boot.loader.grub = { boot.loader.grub.enable = true;
enable = true; boot.loader.grub.device = "nodev";
device = "nodev"; boot.loader.grub.efiSupport = true;
efiSupport = true; boot.loader.grub.efiInstallAsRemovable = true;
efiInstallAsRemovable = true; boot.loader.grub.useOSProber = false;
useOSProber = false;
};
boot.loader.efi = { boot.loader.efi.canTouchEfiVariables = false;
canTouchEfiVariables = false; boot.loader.efi.efiSysMountPoint = "/boot";
efiSysMountPoint = "/boot";
};
############################################################ ############################################################
# INITRD HARDWAREAGNOSTIC + LUKS # INITRD LUKS
############################################################ ############################################################
boot.initrd.availableKernelModules = [ boot.initrd.availableKernelModules = [
@@ -32,8 +28,6 @@
"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;
@@ -46,7 +40,6 @@
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;
@@ -65,22 +58,14 @@
}; };
############################################################ ############################################################
# NETWORKING / LOCALE # LOCALE / NETWORK
############################################################ ############################################################
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";
############################################################
# BLUETOOTH
############################################################
hardware.bluetooth.enable = true;
services.blueman.enable = true;
############################################################ ############################################################
# DESKTOP # DESKTOP
############################################################ ############################################################
@@ -95,7 +80,6 @@
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;
@@ -104,9 +88,11 @@
}; };
############################################################ ############################################################
# PRINTING # BLUETOOTH / PRINTING
############################################################ ############################################################
hardware.bluetooth.enable = true;
services.blueman.enable = true;
services.printing.enable = true; services.printing.enable = true;
############################################################ ############################################################
@@ -115,14 +101,13 @@
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";
}; };
############################################################ ############################################################
# SOFTWARE # PACKAGES
############################################################ ############################################################
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@@ -146,7 +131,7 @@
programs.firefox.enable = true; programs.firefox.enable = true;
############################################################ ############################################################
# PORTABLE USBROOT LOSS → SHUTDOWN # USB ROOT LOSS → SHUTDOWN (FIXED)
############################################################ ############################################################
systemd.services.shutdown-on-root-usb-loss = { systemd.services.shutdown-on-root-usb-loss = {
@@ -159,26 +144,32 @@
ExecStart = pkgs.writeShellScript "watch-root-usb" '' ExecStart = pkgs.writeShellScript "watch-root-usb" ''
set -e set -e
ROOT_SRC="$(findmnt -n -o SOURCE / || true)" 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
ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)"
[ -z "$ROOT_SRC" ] && exit 0 [ -z "$ROOT_SRC" ] && exit 0
if [[ "$ROOT_SRC" == /dev/dm-* ]]; then if [[ "$ROOT_SRC" == /dev/dm-* ]]; then
PARENT="$(lsblk -no PKNAME "$ROOT_SRC")" PARENT="$($LSBLK -no PKNAME "$ROOT_SRC")"
ROOT_DEV="/dev/$PARENT" ROOT_DEV="/dev/$PARENT"
else else
ROOT_DEV="$ROOT_SRC" ROOT_DEV="$ROOT_SRC"
fi fi
TRAN="$(lsblk -no TRAN "$ROOT_DEV" || true)" TRAN="$($LSBLK -no TRAN "$ROOT_DEV" || true)"
[ "$TRAN" != "usb" ] && exec sleep infinity [ "$TRAN" != "usb" ] && exec $SLEEP infinity
DEV_NAME="$(basename "$ROOT_DEV")" DEV_NAME="$($BASENAME "$ROOT_DEV")"
while [ -e "/sys/class/block/$DEV_NAME" ]; do while [ -e "/sys/class/block/$DEV_NAME" ]; do
sleep 1 $SLEEP 1
done done
systemctl poweroff $SYSTEMCTL poweroff
''; '';
Restart = "no"; Restart = "no";
}; };
@@ -193,51 +184,6 @@
"kernel.panic_on_oops" = 1; "kernel.panic_on_oops" = 1;
}; };
############################################################
# GIT AUTOUPDATE
############################################################
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 # SWAP
############################################################ ############################################################
@@ -245,7 +191,7 @@
zramSwap.enable = true; zramSwap.enable = true;
############################################################ ############################################################
# VERSION # SYSTEM VERSION
############################################################ ############################################################
system.stateVersion = "25.11"; system.stateVersion = "25.11";