Update configuration.nix

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

View File

@@ -2,24 +2,20 @@
{
############################################################
# BOOTLOADER GRUB
# BOOTLOADER GRUB
############################################################
boot.loader.grub = {
enable = true;
device = "nodev";
efiSupport = true;
efiInstallAsRemovable = true;
useOSProber = false;
};
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.efi = {
canTouchEfiVariables = false;
efiSysMountPoint = "/boot";
};
boot.loader.efi.canTouchEfiVariables = false;
boot.loader.efi.efiSysMountPoint = "/boot";
############################################################
# INITRD HARDWAREAGNOSTIC + LUKS
# INITRD LUKS
############################################################
boot.initrd.availableKernelModules = [
@@ -32,8 +28,6 @@
"sr_mod"
];
boot.kernelModules = [];
boot.initrd.luks.devices.root = {
device = "/dev/disk/by-partlabel/nixos-crypt";
preLVM = true;
@@ -46,7 +40,6 @@
hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true;
hardware.cpu.intel.updateMicrocode = true;
hardware.cpu.amd.updateMicrocode = true;
@@ -65,22 +58,14 @@
};
############################################################
# NETWORKING / LOCALE
# LOCALE / NETWORK
############################################################
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
############################################################
@@ -95,7 +80,6 @@
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
@@ -104,9 +88,11 @@
};
############################################################
# PRINTING
# BLUETOOTH / PRINTING
############################################################
hardware.bluetooth.enable = true;
services.blueman.enable = true;
services.printing.enable = true;
############################################################
@@ -115,14 +101,13 @@
users.users.user = {
isNormalUser = true;
description = "user";
extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.bash;
initialPassword = "1312";
};
############################################################
# SOFTWARE
# PACKAGES
############################################################
nixpkgs.config.allowUnfree = true;
@@ -146,7 +131,7 @@
programs.firefox.enable = true;
############################################################
# PORTABLE USBROOT LOSS → SHUTDOWN
# USB ROOT LOSS → SHUTDOWN (FIXED)
############################################################
systemd.services.shutdown-on-root-usb-loss = {
@@ -159,26 +144,32 @@
ExecStart = pkgs.writeShellScript "watch-root-usb" ''
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
if [[ "$ROOT_SRC" == /dev/dm-* ]]; then
PARENT="$(lsblk -no PKNAME "$ROOT_SRC")"
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
TRAN="$($LSBLK -no TRAN "$ROOT_DEV" || true)"
[ "$TRAN" != "usb" ] && exec $SLEEP infinity
DEV_NAME="$(basename "$ROOT_DEV")"
DEV_NAME="$($BASENAME "$ROOT_DEV")"
while [ -e "/sys/class/block/$DEV_NAME" ]; do
sleep 1
$SLEEP 1
done
systemctl poweroff
$SYSTEMCTL poweroff
'';
Restart = "no";
};
@@ -193,51 +184,6 @@
"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
############################################################
@@ -245,7 +191,7 @@
zramSwap.enable = true;
############################################################
# VERSION
# SYSTEM VERSION
############################################################
system.stateVersion = "25.11";