Files
nixos-production/configuration.nix
2025-12-19 23:15:48 +00:00

156 lines
4.2 KiB
Nix

{ config, pkgs, ... }:
let
gitRepoUrl = "https://git.skarockoi.de/ska/nixos-production.git";
gitLocalPath = "/var/lib/nixos-config";
in
{
# NO hardware configuration import - we handle boot and filesystems directly
# Generic boot settings for any UEFI system
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.supportedFilesystems = [ "vfat" "ext4" "crypto_LUKS" ];
# Generic kernel modules for most hardware
boot.initrd.availableKernelModules = [
"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;
time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "de_DE.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
services.xserver.xkb.layout = "de";
services.xserver.libinput.enable = true;
console.keyMap = "de";
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
services.printing.enable = true;
users.users.user = {
isNormalUser = true;
description = "user";
extraGroups = [ "networkmanager" "wheel" ];
shell = pkgs.bash;
};
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
git
vim
curl
wget
openssh
obsidian
libreoffice
keepassxc
thunderbird
tor-browser
inkscape
gimp
pdfarranger
epiphany
gnomeExtensions.gsconnect
gnomeExtensions.dash-to-dock
];
programs.firefox.enable = true;
# Keep your auto-update script unchanged
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";
OnUnitActiveSec = "1h";
};
};
system.stateVersion = "25.11";
}