Files
nixos-production/configuration.nix
2025-12-22 11:40:10 +00:00

217 lines
5.6 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{ 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 HARDWAREAGNOSTIC + 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;
};
############################################################
# 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
obsidian
libreoffice
keepassxc
thunderbird
tor-browser
inkscape
gimp
pdfarranger
];
programs.firefox.enable = true;
############################################################
# GIT AUTOUPDATE 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 hourly";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "60s";
OnUnitActiveSec = "1h";
};
};
############################################################
# USB OPTIMIZATIONS
############################################################
zramSwap.enable = true;
############################################################
# NIXOS VERSION
############################################################
system.stateVersion = "25.11";
}