Update configuration.nix

This commit is contained in:
ska
2025-12-19 23:44:54 +00:00
parent 337bcf59e2
commit 55f0fd09a1

View File

@@ -4,40 +4,16 @@ let
gitLocalPath = "/var/lib/nixos-config"; gitLocalPath = "/var/lib/nixos-config";
in in
{ {
# NO hardware configuration import - we handle boot and filesystems directly imports = [ ./hardware-configuration.nix ];
# Generic boot settings for any UEFI system
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
boot.supportedFilesystems = [ "vfat" "ext4" "crypto_LUKS" ];
# Generic kernel modules for most hardware # Fixed: hostname commented out to avoid collisions when cloned to multiple USB sticks
boot.initrd.availableKernelModules = [ # networking.hostName = "nixos-usb"; # ← removed
"xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod"
"usbhid" "hid_generic" "nvme"
];
# Filesystem setup using device paths that work for most USB installations
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
# LUKS encryption setup (will be set up during installation)
boot.initrd.luks.devices."root" = {
device = "/dev/disk/by-label/luks";
preLVM = true;
};
# Your existing configuration below (unchanged)
networking.hostName = "nixos-usb";
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";
i18n.extraLocaleSettings = { i18n.extraLocaleSettings = {
@@ -57,6 +33,7 @@ in
services.xserver.desktopManager.gnome.enable = true; services.xserver.desktopManager.gnome.enable = true;
services.xserver.xkb.layout = "de"; services.xserver.xkb.layout = "de";
services.xserver.libinput.enable = true; services.xserver.libinput.enable = true;
console.keyMap = "de"; console.keyMap = "de";
services.pulseaudio.enable = false; services.pulseaudio.enable = false;
@@ -75,6 +52,8 @@ in
description = "user"; description = "user";
extraGroups = [ "networkmanager" "wheel" ]; extraGroups = [ "networkmanager" "wheel" ];
shell = pkgs.bash; shell = pkgs.bash;
# Fixed: added initial password so you can log in after first boot
initialPassword = "change-me-on-first-boot";
}; };
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@@ -100,11 +79,10 @@ in
programs.firefox.enable = true; programs.firefox.enable = true;
# Keep your auto-update script unchanged # === Auto-update script with full PATH and NIX_PATH ===
environment.etc."update-nixos-config.sh".text = '' environment.etc."update-nixos-config.sh".text = ''
#!/run/current-system/sw/bin/bash #!/run/current-system/sw/bin/bash
set -e set -e
# Ensure all system tools are available
export PATH="/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin" 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" export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
LOCAL_PATH="/var/lib/nixos-config" LOCAL_PATH="/var/lib/nixos-config"
@@ -133,6 +111,7 @@ in
environment.etc."update-nixos-config.sh".mode = "0700"; environment.etc."update-nixos-config.sh".mode = "0700";
# === Systemd service ===
systemd.services.nixos-git-update = { systemd.services.nixos-git-update = {
description = "Update NixOS from public Git config"; description = "Update NixOS from public Git config";
script = "/etc/update-nixos-config.sh"; script = "/etc/update-nixos-config.sh";
@@ -152,5 +131,12 @@ in
}; };
}; };
# Fixed: added USB and storage modules for reliable boot from USB stick
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "usb_storage" "sd_mod" "sr_mod" ];
# Fixed: added ZRAM to avoid crashes due to low RAM on portable systems
zramSwap.enable = true;
# Left unchanged per your request
system.stateVersion = "25.11"; system.stateVersion = "25.11";
} }