Files
nixos-production/configuration.nix
2025-12-25 18:40:43 +00:00

222 lines
5.7 KiB
Nix

{ config, pkgs, ... }:
{
############################################################
# BOOTLOADER - GRUB
############################################################
boot.loader.grub = {
enable = true;
device = "nodev";
efiSupport = true;
efiInstallAsRemovable = true;
useOSProber = false;
};
boot.loader.efi = {
canTouchEfiVariables = false;
efiSysMountPoint = "/boot";
};
############################################################
# INITRD - HARDWARE-AGNOSTIC + LUKS
############################################################
boot.initrd.availableKernelModules = [
"usb_storage"
"xhci_hcd"
"ehci_pci"
"ahci"
"sd_mod"
"nvme"
"sr_mod"
];
boot.kernelModules = [];
boot.initrd.luks.devices.root = {
device = "/dev/disk/by-partlabel/nixos-crypt";
preLVM = true;
allowDiscards = true;
};
boot.plymouth.enable = true;
boot.initrd.systemd.enable = true;
############################################################
# FIRMWARE - WIDE HARDWARE SUPPORT
############################################################
hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true;
hardware.cpu.intel.updateMicrocode = true;
hardware.cpu.amd.updateMicrocode = true;
############################################################
# FILESYSTEMS - BASED ON LABELS
############################################################
fileSystems."/" = {
device = "/dev/disk/by-label/nixos-root";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/EFI";
fsType = "vfat";
};
############################################################
# NETWORKING
############################################################
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 - GNOME
############################################################
services.displayManager.gdm.enable = true;
services.desktopManager.gnome.enable = true;
services.libinput.enable = true;
############################################################
# AUDIO - PIPEWIRE
############################################################
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
############################################################
# PRINTING
############################################################
services.printing.enable = true;
############################################################
# USER
############################################################
users.users.user = {
isNormalUser = true;
description = "user";
extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.bash;
initialPassword = "1312";
};
############################################################
# SOFTWARE
############################################################
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
git
vim
curl
wget
openssh
gnomeExtensions.dash-in-panel
gnomeExtensions.dash-to-panel
obsidian
libreoffice
keepassxc
thunderbird
tor-browser
inkscape
gimp
pdfarranger
];
programs.firefox.enable = true;
############################################################
# GIT AUTO-UPDATE 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 at startup";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "60s";
};
};
############################################################
# USB OPTIMIZATIONS
############################################################
zramSwap.enable = true;
############################################################
# NIXOS VERSION
############################################################
system.stateVersion = "25.11";
}