From 7ab4886e90ff6d5d1989259922cda57801749916 Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Tue, 12 Mar 2024 21:24:29 +0100 Subject: [PATCH] Added configuration for desktop --- flake.nix | 19 ++++++++++- hosts/desktop/default.nix | 42 ++++++++++++++++++++++++ hosts/desktop/hardware-configuration.nix | 39 ++++++++++++++++++++++ hosts/desktop/home.nix | 30 +++++++++++++++++ hosts/laptop/home.nix | 2 +- modules/system/desktop/nvidia.nix | 38 +++++++++++++++++++++ modules/system/desktop/plasma.nix | 19 +++++++++++ modules/system/programs/sunshine.nix | 25 ++++++++++++++ modules/system/utils/firewall.nix | 7 ++++ 9 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 hosts/desktop/default.nix create mode 100644 hosts/desktop/hardware-configuration.nix create mode 100644 hosts/desktop/home.nix create mode 100644 modules/system/desktop/nvidia.nix create mode 100644 modules/system/desktop/plasma.nix create mode 100644 modules/system/programs/sunshine.nix create mode 100644 modules/system/utils/firewall.nix diff --git a/flake.nix b/flake.nix index b8400d5..26ca53b 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ in { nixosConfigurations = { - laptop = nixpkgs.lib.nixosSystem { + xv-laptop = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ @@ -58,5 +58,22 @@ ]; }; }; + nixosConfigurations = { + xv-desktop = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) + + ./hosts/desktop + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.extraSpecialArgs = { inherit inputs nix-colors; }; + home-manager.users.xeovalyte.imports = [ ./hosts/desktop/home.nix ]; + } + ]; + }; + }; }; } diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix new file mode 100644 index 0000000..acbd0bd --- /dev/null +++ b/hosts/desktop/default.nix @@ -0,0 +1,42 @@ +{ config, pkgs, ... }: + +{ + imports = [ # Include the results of the hardware scan. + ./hardware-configuration.nix + #../../modules/system/desktop/hyprland.nix + ../../modules/system/desktop/plasma.nix + ../../modules/system/desktop/nvidia.nix + ../../modules/system/programs/sunshine.nix + #../../modules/system/programs/syncthing.nix + ../../modules/system/programs/thunar.nix + ../../modules/system/utils/common.nix + ../../modules/system/utils/firewall.nix + ../../modules/system/utils/fprint.nix + ../../modules/system/utils/garbage-collection.nix + ../../modules/system/utils/locale.nix + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Bootloader. + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.grub = { + enable = true; + efiSupport = true; + device = "nodev"; + }; + + networking.hostName = "xv-desktop"; # Define your hostname. + networking.interfaces.enp7s0.wakeOnLan.enable = true; + + users.users.xeovalyte = { + isNormalUser = true; + description = "Timo Boomers"; + extraGroups = [ "networkmanager" "wheel" "dialout" ]; + }; + + services.printing.enable = true; + + system.stateVersion = "23.11"; + +} diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix new file mode 100644 index 0000000..5bb716f --- /dev/null +++ b/hosts/desktop/hardware-configuration.nix @@ -0,0 +1,39 @@ +# 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 = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/66480545-d8cb-4853-be36-bb52526a2293"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/1F0A-7888"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/e67f24cf-f7a6-4a92-87cc-0ae047dbb4df"; } + ]; + + # 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 true; + # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix new file mode 100644 index 0000000..d01650d --- /dev/null +++ b/hosts/desktop/home.nix @@ -0,0 +1,30 @@ +{ pkgs, ... }: + +{ + imports = [ + #../../modules/home/desktop/hyprland + ../../modules/home/programs/common.nix + ../../modules/home/programs/firefox.nix + ../../modules/home/programs/kitty.nix + ../../modules/home/programs/neovim + ../../modules/home/programs/git.nix + ../../modules/home/programs/ssh.nix + ../../modules/home/theme + ../../modules/home/theme/blueish.nix + ../../modules/home/utils/fonts.nix + ]; + + home = { + username = "xeovalyte"; + homeDirectory = "/home/xeovalyte"; + }; + + home.packages = with pkgs; [ + # Desktop Applications + kdenlive + gthumb + unstable.arduino-ide + ]; + + home.stateVersion = "23.11"; +} diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index f1de191..2987353 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -2,7 +2,7 @@ { imports = [ - ../../modules/home/desktop/hyprland + #../../modules/home/desktop/hyprland ../../modules/home/programs/common.nix ../../modules/home/programs/firefox.nix ../../modules/home/programs/kitty.nix diff --git a/modules/system/desktop/nvidia.nix b/modules/system/desktop/nvidia.nix new file mode 100644 index 0000000..87ccc77 --- /dev/null +++ b/modules/system/desktop/nvidia.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, nixpkgs, ... }: + +{ + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "nvidia-x11" + "nvidia-settings" + ]; + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + services.xserver.videoDrivers = ["nvidia"]; # or "nvidiaLegacy470 etc. + + hardware.nvidia = { + + modesetting.enable = true; + + powerManagement.enable = false; + + # Fine-grained power management. Turns off GPU when not in use. + # Experimental and only works on modern Nvidia GPUs (Turing or newer). + powerManagement.finegrained = false; + + # Use the NVidia open source kernel module (not to be confused with the + # independent third-party "nouveau" open source driver). + # Support is limited to the Turing and later architectures. Full list of + # supported GPUs is at: + # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus + # Only available from driver 515.43.04+ + # Currently alpha-quality/buggy, so false is currently the recommended setting. + open = false; + nvidiaSettings = true; + + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; +} diff --git a/modules/system/desktop/plasma.nix b/modules/system/desktop/plasma.nix new file mode 100644 index 0000000..7460d48 --- /dev/null +++ b/modules/system/desktop/plasma.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + services.xserver.enable = true; + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + programs.dconf.enable = true; +} diff --git a/modules/system/programs/sunshine.nix b/modules/system/programs/sunshine.nix new file mode 100644 index 0000000..405a3a6 --- /dev/null +++ b/modules/system/programs/sunshine.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + unstable.sunshine + ]; + + services.udev.extraRules = '' + KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess" + ''; + + services.avahi = { + enable = true; + }; + + networking.firewall = { + allowedTCPPorts = [ 48010 ]; + allowedTCPPortRanges = [ + { from = 47984; to = 47990; } + ]; + allowedUDPPortRanges = [ + { from = 47998; to = 48000; } + ]; + }; +} diff --git a/modules/system/utils/firewall.nix b/modules/system/utils/firewall.nix new file mode 100644 index 0000000..7bf3355 --- /dev/null +++ b/modules/system/utils/firewall.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + networking.firewall = { + enable = true; + }; +}