From 1a2bc74221df6d5084330265df78a60b4904386f Mon Sep 17 00:00:00 2001 From: ChUrl Date: Sun, 9 Jul 2023 10:21:51 +0200 Subject: [PATCH] Add servenix system config --- system/servenix/default.nix | 67 +++++++++++++ system/servenix/hardware-configuration.nix | 108 +++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 system/servenix/default.nix create mode 100644 system/servenix/hardware-configuration.nix diff --git a/system/servenix/default.nix b/system/servenix/default.nix new file mode 100644 index 00000000..0f5ed477 --- /dev/null +++ b/system/servenix/default.nix @@ -0,0 +1,67 @@ +{ + inputs, + config, + lib, + mylib, + pkgs, + ... +}: rec { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ../modules + + # inputs.musnix.nixosModules.musnix + ]; + + modules = { + containers = { + enable = true; + + homeassistant.enable = false; + stablediffusion.enable = true; + jellyfin.enable = true; + fileflows.enable = false; + sonarr.enable = true; + radarr.enable = true; + hydra.enable = true; + sabnzbd.enable = true; + }; + + systemd-networkd = { + wireguard-tunnels = { + wg0-de-115 = ( + mylib.networking.mkWireguardService + "wg0-de-115" + "proton-de-115.key" + "9+CorlxrTsQR7qjIOVKsEkk8Z7UUS5WT3R1ccF7a0ic=" + "194.126.177.14" + ); + + wg0-lu-16 = ( + mylib.networking.mkWireguardService + "wg0-lu-16" + "proton-lu-16.key" + "asu9KtQoZ3iKwELsDTgjPEiFNcD1XtgGgy3O4CZFg2w=" + "92.223.89.133" + ); + }; + }; + }; + + # Low latency audio + # musnix = { + # enable = true; + # # musnix.soundcardPciId = ; + # }; + + services.xserver = { + # Configure keymap in X11 + layout = "us"; + xkbVariant = "altgr-intl"; + + # videoDrivers = [ "nvidia" ]; # NVIDIA + # videoDrivers = ["amdgpu"]; + videoDrivers = ["intel"]; + }; +} diff --git a/system/servenix/hardware-configuration.nix b/system/servenix/hardware-configuration.nix new file mode 100644 index 00000000..0e98bb31 --- /dev/null +++ b/system/servenix/hardware-configuration.nix @@ -0,0 +1,108 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [(modulesPath + "/installer/scan/not-detected.nix")]; + + boot = { + initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"]; + # Enable early Nvidia kernel modesetting + # https://wiki.archlinux.org/title/GDM#GDM_ignores_Wayland_and_uses_X.Org_by_default (not fixed by this) + # https://wiki.archlinux.org/title/Kernel_mode_setting#Early_KMS_start + # initrd.kernelModules = [ "nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" ]; # NVIDIA + initrd.kernelModules = ["amdgpu"]; # Initrd modules are always loaded, e.g. when they are required to mount the rootfs + # kernelModules = ["kvm-intel" "iwlwifi"]; + kernelModules = ["kvm-amd"]; + + # extraModprobeConfig = '' + # options iwlwifi 11n_disable=1 wd_disable=0 + # ''; + + # Specific to used kernel (currently linux_zen) + extraModulePackages = with config.boot.kernelPackages; [ + # new-lg4ff # Logitech force feedback + v4l2loopback + ]; + }; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/68bd46a0-e95c-4764-a006-44bd9975a6c2"; + fsType = "ext4"; + options = [ "noatime" "nodiratime" "discard" ]; + }; + + fileSystems."/boot/efi" = { + device = "/dev/disk/by-uuid/36A9-3D74"; + fsType = "vfat"; + }; + + swapDevices = lib.mkForce [ + # { + # device = "/var/swap"; + # # size = 1024 * 16 * 2; # twice the RAM for hibernation + # size = 1024 * 8; # Without hibernation 4.0 GB to 0.5 x RAM + # } + ]; + + # 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 + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault false; # NOTE: Set to false bc systemd-networkd + # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.enp4s0u2.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + # networking.networkmanager.enable = true; + # networking.wireless.iwd.enable = true; + # networking.networkmanager.wifi.backend = "iwd"; + + nixpkgs.config.allowUnfree = true; + + hardware = { + # Use all redistributable firmware (i.e. nonfree) + enableAllFirmware = true; + enableRedistributableFirmware = true; + # cpu.intel.updateMicrocode = true; + cpu.amd.updateMicrocode = true; + + # nvidia.modesetting.enable = true; # Not officially supported by NVidia but needed for wayland + # video.hidpi.enable = lib.mkDefault true; # No longer has any effect + opengl.enable = true; + + # Vulkan + opengl.driSupport = true; + opengl.driSupport32Bit = true; + + # AMD: https://nixos.wiki/wiki/AMD_GPU + opengl.extraPackages = with pkgs; [ + # amdvlk # RADV (mesa) and AMDVLK (amd) can be used simultaneously + + # OpenCL + # rocm-opencl-icd + # rocm-opencl-runtime + # rocm-runtime # Wiki doesn't mention this, but it exists... + + # TODO: Disabled for the moment, because hardware acceleration crashes AMDGPU driver + # VAAPI/VDPAU: https://nixos.wiki/wiki/Accelerated_Video_Playback + # vaapiVdpau # Taken from wiki + # libvdpau-va-gl # Taken from wiki + # libvdpau # NOTE: Don't know if needed/where it belongs... + # libva # NOTE: Don't know if needed/where it belongs... + ]; + + sane.enable = true; # Scanning + + xpadneo.enable = true; # Xbox Controller + }; + + environment.variables.AMD_VULKAN_ICD = "RADV"; # Choose mesa driver by default + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; +}