Compare commits
10 Commits
f98a761db3
...
main
Author | SHA1 | Date | |
---|---|---|---|
0032d25ba8 | |||
c1e5ba2297 | |||
62b1cd72db | |||
34495ccc71 | |||
1e19b7ca2f | |||
fcab24ae8d | |||
5921272649 | |||
a55b594483 | |||
36c3c1eae6 | |||
b53c946c39 |
@ -1,11 +1,33 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
let
|
||||||
imports = [ ./hardware ]; # bindet die auto-generierte HW-Datei ein
|
hdmiHandler = pkgs.writeShellScript "hdmi-display-manager" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
PORT=$(ls /sys/class/drm/card*-HDMI-A-*/*status 2>/dev/null | head -n1 || true)
|
||||||
|
[[ -z "$PORT" ]] && exit 0
|
||||||
|
status=$(cat "$PORT" || echo "disconnected")
|
||||||
|
|
||||||
|
if [[ "$status" == "connected" ]]; then
|
||||||
|
systemctl start display-manager.service
|
||||||
|
else
|
||||||
|
systemctl stop display-manager.service
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ ./hardware/hardware-configuration.nix ];
|
||||||
|
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
boot.initrd.kernelModules = [ "overlay" "vmd" ];
|
boot.initrd.kernelModules = [ "overlay" "vmd" ];
|
||||||
|
boot.initrd.systemd.tmpfiles.settings."nixdirs" = {
|
||||||
|
"/nix".d = { mode = "0755"; type = "d"; user = "root"; group = "root";};
|
||||||
|
"/nix/.ro-store".d = { mode = "0755"; type = "d"; user = "root"; group = "root";};
|
||||||
|
"/nix/.rw-store".d = { mode = "0755"; type = "d"; user = "root"; group = "root";};
|
||||||
|
};
|
||||||
boot.zfs.extraPools = ["tank"];
|
boot.zfs.extraPools = ["tank"];
|
||||||
|
|
||||||
networking.hostName = "nix-nas";
|
networking.hostName = "nix-nas";
|
||||||
@ -14,11 +36,13 @@
|
|||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{ device = "rpool/root";
|
{ device = "rpool/root";
|
||||||
fsType = "zfs";
|
fsType = "zfs";
|
||||||
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/nix" =
|
fileSystems."/nix" =
|
||||||
{ device = "rpool/nix";
|
{ device = "rpool/nix";
|
||||||
fsType = "zfs";
|
fsType = "zfs";
|
||||||
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/home" =
|
fileSystems."/home" =
|
||||||
@ -36,21 +60,109 @@
|
|||||||
users.users.nicole = {
|
users.users.nicole = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
hashedPassword = "$6$p73d5mOLoSuJGOol$KRlszaPXZK9/frADlfR3kAr/57DD5f4.CPTGNNX80QWEWFE5y.bM1WiZwmRHiAlrws3q/zCDQ6AqeSyCUX.8U/";
|
hashedPassword = "$6$p73d5mOLoSuJGOol$KRlszaPXZK9/frADlfR3kAr/57DD5f4.CPTGNNX80QWEWFE5y.bM1WiZwmRHiAlrws3q/zCDQ6AqeSyCUX.8U/";
|
||||||
extraGroups = [ "wheel" "docker" "libvirtd" ];
|
extraGroups = [ "wheel" "docker" "libvirtd" "video" "render" ];
|
||||||
openssh.authorizedKeys.keys = [
|
openssh.authorizedKeys.keys = [
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGAsiKDWCwyf1usprg3K6Zk0xE9S4DX6+Bc4+nIOZGmf drezil@Manticore"
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGAsiKDWCwyf1usprg3K6Zk0xE9S4DX6+Bc4+nIOZGmf drezil@Manticore"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
users.users.kodi = {
|
||||||
|
isNormalUser = true;
|
||||||
|
home = "/home/kodi";
|
||||||
|
description = "Kodi Auto-Login User";
|
||||||
|
extraGroups = [ "video" "render" ]; # GPU-/DRM-Zugriff
|
||||||
|
linger = true; # User-Scope darf headless laufen
|
||||||
|
# kein wheel ⇒ kein sudo
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
system.stateVersion = "25.05"; # ← einmalig festnageln
|
system.stateVersion = "25.05"; # ← einmalig festnageln
|
||||||
security.sudo.wheelNeedsPassword = false;
|
security.sudo.wheelNeedsPassword = false;
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
services.zfs.autoScrub.enable = true; # Snapshots & Details kommen später
|
services.zfs.autoScrub.enable = true; # Snapshots & Details kommen später
|
||||||
|
|
||||||
|
systemd.services.zfs-prune-snapshots = {
|
||||||
|
description = "Remove ZFS snapshots older than policy";
|
||||||
|
serviceConfig.ExecStart = "/run/current-system/sw/bin/zfs-prune-snapshots -r --keep=2w";
|
||||||
|
startAt = "daily";
|
||||||
|
};
|
||||||
|
systemd.services.systemd-udev-settle.enable = false;
|
||||||
|
systemd.services.NetworkManager-wait-online.enable = false;
|
||||||
|
|
||||||
|
|
||||||
# Wir pinnen den Kernel, bis ZFS 2.3.x für 6.13 bereit ist
|
# Wir pinnen den Kernel, bis ZFS 2.3.x für 6.13 bereit ist
|
||||||
boot.kernelPackages = pkgs.linuxPackages_6_12;
|
boot.kernelPackages = pkgs.linuxPackages_6_12;
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [ git vim zfs ];
|
##########################################################################
|
||||||
|
### SYSTEM PACKAGES #####################################################
|
||||||
|
##########################################################################
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
git tig vim zfs virt-viewer
|
||||||
|
kodi netflix
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
#### Virtualisation
|
||||||
|
|
||||||
|
virtualisation.docker.enable = true;
|
||||||
|
virtualisation.libvirtd.enable = true;
|
||||||
|
users.groups.docker.members = [ "nicole" ];
|
||||||
|
programs.virt-manager.enable = true;
|
||||||
|
|
||||||
|
|
||||||
|
#### nix-Cache
|
||||||
|
# --- Binary-Cache
|
||||||
|
services.nix-serve = {
|
||||||
|
enable = true;
|
||||||
|
secretKeyFile = "/var/cache/nix/secret-key";
|
||||||
|
openFirewall = true;
|
||||||
|
port = 5000;
|
||||||
|
};
|
||||||
|
|
||||||
|
nix.settings = {
|
||||||
|
substituters = [ "http://nix-nas:5000" "https://cache.nixos.org" ];
|
||||||
|
trusted-public-keys = [
|
||||||
|
"nas-cache:rgCDn9SwmvxvhjiEiRgrjAuAEyRiJT/aBIlywetuypM="
|
||||||
|
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" # Standard-Key vom upstream Cache
|
||||||
|
];
|
||||||
|
secret-key-files = [ "/var/cache/nix/secret-key" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
### Kodi & TV-Detect #####################################################
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
|
services.xserver = {
|
||||||
|
enable = true;
|
||||||
|
videoDrivers = [ "modesetting" ]; # Intel iGPU
|
||||||
|
desktopManager.kodi = {
|
||||||
|
enable = true;
|
||||||
|
package = (pkgs.kodi.withPackages (kodiPkgs: with kodiPkgs; [
|
||||||
|
jellyfin
|
||||||
|
netflix
|
||||||
|
mediacccde
|
||||||
|
mediathekview
|
||||||
|
sponsorblock
|
||||||
|
youtube
|
||||||
|
]));
|
||||||
|
};
|
||||||
|
displayManager.startx.enable = false; # nutzt LightDM intern
|
||||||
|
xkb = {
|
||||||
|
layout = "de,de";
|
||||||
|
variant = ",neo";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
console.useXkbConfig = true;
|
||||||
|
services.displayManager.autoLogin = {
|
||||||
|
enable = true;
|
||||||
|
user = "kodi";
|
||||||
|
};
|
||||||
|
|
||||||
|
### UDEV-Regel + Skript ##################################################
|
||||||
|
services.udev.extraRules = ''
|
||||||
|
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="${hdmiHandler}"
|
||||||
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
./disko.nix # disko partitionierung
|
./disko.nix # disko partitionierung
|
||||||
./hardware/hardware-configuration.nix # generiertes hardware-configuration.nix
|
./hardware/hardware-configuration.nix # generiertes hardware-configuration.nix
|
||||||
./configuration.nix # deine eigentliche Config
|
./configuration.nix # deine eigentliche Config
|
||||||
|
./modules/zfs.nix
|
||||||
disko.nixosModules.disko
|
disko.nixosModules.disko
|
||||||
nixos-hardware.nixosModules.common-pc-ssd
|
nixos-hardware.nixosModules.common-pc-ssd
|
||||||
];
|
];
|
||||||
|
@ -8,46 +8,18 @@
|
|||||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ];
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" ];
|
||||||
boot.initrd.kernelModules = [ ];
|
boot.initrd.kernelModules = [ ];
|
||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
# fileSystems."/" =
|
|
||||||
# { device = "tmpfs";
|
|
||||||
# fsType = "tmpfs";
|
|
||||||
# };
|
|
||||||
|
|
||||||
fileSystems."/iso" =
|
|
||||||
{ device = "/dev/disk/by-uuid/1980-01-01-00-00-00-00";
|
|
||||||
fsType = "iso9660";
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/nix/.ro-store" =
|
|
||||||
{ device = "/iso/nix-store.squashfs";
|
|
||||||
fsType = "squashfs";
|
|
||||||
options = [ "loop" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/nix/.rw-store" =
|
|
||||||
{ device = "tmpfs";
|
|
||||||
fsType = "tmpfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/nix/store" =
|
|
||||||
{ device = "overlay";
|
|
||||||
fsType = "overlay";
|
|
||||||
};
|
|
||||||
|
|
||||||
swapDevices = [ ];
|
|
||||||
|
|
||||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
# still possible to use this option, but it's recommended to use it in conjunction
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
networking.useDHCP = lib.mkDefault true;
|
networking.useDHCP = lib.mkDefault true;
|
||||||
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
|
# networking.interfaces.enp2s0.useDHCP = lib.mkDefault true;
|
||||||
# networking.interfaces.enp6s0.useDHCP = lib.mkDefault true;
|
# networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
39
modules/zfs.nix
Normal file
39
modules/zfs.nix
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
#### 1. Pool-Eigenschaften (permanent) ##############################
|
||||||
|
# wird von systemd-Units bei jedem Boot angewendet
|
||||||
|
services.zfs = {
|
||||||
|
trim.enable = true; # weekly zpool trim
|
||||||
|
autoScrub = {
|
||||||
|
enable = true; # weekly scrub
|
||||||
|
interval = "Sun 04:00"; # optional ändern
|
||||||
|
pools = [ "rpool" "tank" ];
|
||||||
|
};
|
||||||
|
autoSnapshot = {
|
||||||
|
enable = true;
|
||||||
|
frequent = 4; # alle 15 min, 4 Aufbewahrung
|
||||||
|
hourly = 24;
|
||||||
|
daily = 7;
|
||||||
|
weekly = 4;
|
||||||
|
monthly = 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#### 2. ARC-Größe begrenzen (z. B. 8 GiB) ###########################
|
||||||
|
# 8 * 1024^3 = 8589934592
|
||||||
|
boot.kernelParams = [ "zfs.zfs_arc_max=8589934592" ]; # ≈ 16 % von 48 GB RAM :contentReference[oaicite:0]{index=0}
|
||||||
|
|
||||||
|
#### 3. Zusätzliche Module / Tools ##################################
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
zfs # zpool, zfs, arc_summary
|
||||||
|
zfs-prune-snapshots
|
||||||
|
];
|
||||||
|
|
||||||
|
#### 4. Optional: Sanoid statt OpenSolaris-Snapshots ################
|
||||||
|
# services.sanoid.enable = true;
|
||||||
|
# services.sanoid.datasets."tank/media" = {
|
||||||
|
# hourly = 24; daily = 7; monthly = 3;
|
||||||
|
# };
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user