commit
						be60d90339
					
				
					 17 changed files with 159 additions and 69 deletions
				
			
		
							
								
								
									
										20
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
										
									
									
									
								
							|  | @ -1,11 +1,13 @@ | ||||||
| # nixos-configuration | # nixos-configuration | ||||||
| 
 | 
 | ||||||
| When adding a new host: | / | ||||||
| 1. install NixOS via the graphical installer | ├── modules | ||||||
| 2. `mv /etc/hardware-configuration ./devicename-hardware-configuration.nix` | │  ├── desktop | ||||||
| 3. copy an existing devicename.nix | │  ├── hardware (includes hostname.nix) | ||||||
| 5. change import to `new-devicename-hardware-configuration.nix` | │  └── users | ||||||
| 6. set the hostname and optional imports in `new-devicename.nix` | └── hostname.nix (imports modules) | ||||||
| 7. `ln -s ./new-devicename.nix /etc/nixos/configuration.nix` | 
 | ||||||
| 8. `sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager` | When adding a new host: `ln -s ./new-devicename.nix /etc/nixos/configuration.nix` | ||||||
| 9. apply | 
 | ||||||
|  | Use `sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager` to add home manager support. | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| {pkgs, ...}: { | {...}: { | ||||||
|   imports = [ |   imports = [ | ||||||
|     (import ./modules { |     (import ./modules { | ||||||
|       hostName = "hetzner-vpn1"; |       hostName = "hetzner-vpn1"; | ||||||
|  |  | ||||||
|  | @ -38,10 +38,15 @@ in { | ||||||
|       alsa.enable = true; |       alsa.enable = true; | ||||||
|       alsa.support32Bit = true; |       alsa.support32Bit = true; | ||||||
|       pulse.enable = true; |       pulse.enable = true; | ||||||
|  |       #jack.enable = true; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     programs = { |     programs = { | ||||||
|       kdeconnect.enable = true; |       kdeconnect.enable = true; | ||||||
|  |       firefox = { | ||||||
|  |         enable = true; | ||||||
|  |         languagePacks = ["en-US" "de"]; | ||||||
|  |       }; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     # unblock kde connect / gsconnect |     # unblock kde connect / gsconnect | ||||||
|  | @ -86,6 +91,14 @@ in { | ||||||
|       "electron-12.2.3" |       "electron-12.2.3" | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|  |     my.allowUnfreePackages = [ | ||||||
|  |       "insync" | ||||||
|  |       "insync-pkg" | ||||||
|  | 
 | ||||||
|  |       "rider" | ||||||
|  |       "pycharm-professional" | ||||||
|  |     ]; | ||||||
|  | 
 | ||||||
|     fonts = { |     fonts = { | ||||||
|       fontconfig.defaultFonts.monospace = ["FiraCode Nerd Font"]; |       fontconfig.defaultFonts.monospace = ["FiraCode Nerd Font"]; | ||||||
|       fonts = with pkgs; [ |       fonts = with pkgs; [ | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ in { | ||||||
| 
 | 
 | ||||||
|   config = lib.mkIf isEnabled { |   config = lib.mkIf isEnabled { | ||||||
|     hardware.opengl = { |     hardware.opengl = { | ||||||
|  |       driSupport = true; | ||||||
|       driSupport32Bit = true; |       driSupport32Bit = true; | ||||||
|       extraPackages = with pkgs; [mangohud]; |       extraPackages = with pkgs; [mangohud]; | ||||||
|       extraPackages32 = with pkgs; [mangohud]; |       extraPackages32 = with pkgs; [mangohud]; | ||||||
|  | @ -41,5 +42,11 @@ in { | ||||||
|         dedicatedServer.openFirewall = true; |         dedicatedServer.openFirewall = true; | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|  | 
 | ||||||
|  |     my.allowUnfreePackages = [ | ||||||
|  |       "steam" | ||||||
|  |       "steam-original" | ||||||
|  |       "steam-run" | ||||||
|  |     ]; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										47
									
								
								modules/hardware/amd.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								modules/hardware/amd.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,47 @@ | ||||||
|  | { | ||||||
|  |   lib, | ||||||
|  |   config, | ||||||
|  |   pkgs, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   cfg = config.my.hardware.amd; | ||||||
|  | in { | ||||||
|  |   options.my.hardware.amd = { | ||||||
|  |     cpu = lib.mkEnableOption "amd cpu"; | ||||||
|  |     gpu = lib.mkEnableOption "amd gpu"; | ||||||
|  |     radeon = lib.mkEnableOption "amd legacy gpu"; # old hardware, dont judge | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = lib.mkMerge [ | ||||||
|  |     (lib.mkIf cfg.cpu { | ||||||
|  |       boot.kernelModules = ["kvm-amd"]; | ||||||
|  |       hardware.cpu.amd.updateMicrocode = true; | ||||||
|  |     }) | ||||||
|  | 
 | ||||||
|  |     (lib.mkIf cfg.gpu { | ||||||
|  |       boot.kernelModules = ["amdgpu"]; | ||||||
|  |       services.xserver.videoDrivers = ["amdgpu"]; | ||||||
|  | 
 | ||||||
|  |       hardware.opengl = { | ||||||
|  |         extraPackages = with pkgs; [ | ||||||
|  |           amdvlk | ||||||
|  |         ]; | ||||||
|  |         extraPackages32 = with pkgs; [ | ||||||
|  |           driversi686Linux.amdvlk | ||||||
|  |         ]; | ||||||
|  |       }; | ||||||
|  | 
 | ||||||
|  |       environment.systemPackages = with pkgs; [ | ||||||
|  |         unstable.nvtop-amd | ||||||
|  |       ]; | ||||||
|  |     }) | ||||||
|  | 
 | ||||||
|  |     (lib.mkIf cfg.radeon { | ||||||
|  |       boot.kernelModules = ["radeon"]; | ||||||
|  |       services.xserver.videoDrivers = ["radeon"]; | ||||||
|  |       environment.systemPackages = with pkgs; [ | ||||||
|  |         radeontop | ||||||
|  |       ]; | ||||||
|  |     }) | ||||||
|  |   ]; | ||||||
|  | } | ||||||
|  | @ -1,15 +0,0 @@ | ||||||
| { |  | ||||||
|   lib, |  | ||||||
|   config, |  | ||||||
|   pkgs, |  | ||||||
|   ... |  | ||||||
| }: let |  | ||||||
|   isEnabled = config.my.hardware.isAmdCpu; |  | ||||||
| in { |  | ||||||
|   options.my.hardware.isAmdCpu = lib.mkEnableOption "amd cpu"; |  | ||||||
| 
 |  | ||||||
|   config = lib.mkIf isEnabled { |  | ||||||
|     boot.kernelModules = ["kvm-amd"]; |  | ||||||
|     hardware.cpu.amd.updateMicrocode = true; |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
|  | @ -1,17 +0,0 @@ | ||||||
| { |  | ||||||
|   lib, |  | ||||||
|   config, |  | ||||||
|   pkgs, |  | ||||||
|   ... |  | ||||||
| }: let |  | ||||||
|   isEnabled = config.my.hardware.isAmdGpu; |  | ||||||
| in { |  | ||||||
|   options.my.hardware.isAmdGpu = lib.mkEnableOption "amd gpu"; |  | ||||||
| 
 |  | ||||||
|   config = lib.mkIf isEnabled { |  | ||||||
|     environment.systemPackages = with pkgs; [ |  | ||||||
|       radeontop |  | ||||||
|       amdvlk |  | ||||||
|     ]; |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
|  | @ -9,9 +9,8 @@ in { | ||||||
|     (modulesPath + "/installer/scan/not-detected.nix") |     (modulesPath + "/installer/scan/not-detected.nix") | ||||||
|     (builtins.toString ./. + "/${hostName}.nix") |     (builtins.toString ./. + "/${hostName}.nix") | ||||||
|     ./common-desktop.nix |     ./common-desktop.nix | ||||||
|     ./amdcpu.nix |     ./amd.nix | ||||||
|     ./amdgpu.nix |     ./intel.nix | ||||||
|     ./intelcpu.nix |  | ||||||
|   ]; |   ]; | ||||||
| 
 | 
 | ||||||
|   options.my.modulesCfg.hostName = lib.mkOption { |   options.my.modulesCfg.hostName = lib.mkOption { | ||||||
|  |  | ||||||
							
								
								
									
										39
									
								
								modules/hardware/intel.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								modules/hardware/intel.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | ||||||
|  | { | ||||||
|  |   lib, | ||||||
|  |   config, | ||||||
|  |   pkgs, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   cfg = config.my.hardware.intel; | ||||||
|  | in { | ||||||
|  |   options.my.hardware.intel = { | ||||||
|  |     cpu = lib.mkEnableOption "intel cpu"; | ||||||
|  |     iGpu = lib.mkEnableOption "intel integrated gpu"; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = lib.mkMerge [ | ||||||
|  |     (lib.mkIf cfg.cpu { | ||||||
|  |       boot.kernelModules = ["kvm-intel"]; | ||||||
|  |       hardware.cpu.intel.updateMicrocode = true; | ||||||
|  |     }) | ||||||
|  |     (lib.mkIf cfg.iGpu { | ||||||
|  |       hardware.opengl = { | ||||||
|  |         extraPackages = with pkgs; [ | ||||||
|  |           intel-media-driver | ||||||
|  |           vaapiIntel | ||||||
|  |           vaapiVdpau | ||||||
|  |           libvdpau-va-gl | ||||||
|  |         ]; | ||||||
|  |         extraPackages32 = with pkgs.pkgsi686Linux; [ | ||||||
|  |           intel-media-driver | ||||||
|  |           vaapiIntel | ||||||
|  |           vaapiVdpau | ||||||
|  |           libvdpau-va-gl | ||||||
|  |         ]; | ||||||
|  |       }; | ||||||
|  |       environment.systemPackages = with pkgs; [ | ||||||
|  |         unstable.nvtop-intel | ||||||
|  |       ]; | ||||||
|  |     }) | ||||||
|  |   ]; | ||||||
|  | } | ||||||
|  | @ -1,14 +0,0 @@ | ||||||
| { |  | ||||||
|   lib, |  | ||||||
|   config, |  | ||||||
|   ... |  | ||||||
| }: let |  | ||||||
|   isEnabled = config.my.hardware.isIntelCpu; |  | ||||||
| in { |  | ||||||
|   options.my.hardware.isIntelCpu = lib.mkEnableOption "intel cpu"; |  | ||||||
| 
 |  | ||||||
|   config = lib.mkIf isEnabled { |  | ||||||
|     boot.kernelModules = ["kvm-intel"]; |  | ||||||
|     hardware.cpu.intel.updateMicrocode = true; |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
|  | @ -2,8 +2,11 @@ | ||||||
|   config = { |   config = { | ||||||
|     my.hardware = { |     my.hardware = { | ||||||
|       enableCommonDesktopSettings = true; |       enableCommonDesktopSettings = true; | ||||||
|       isIntelCpu = true; |       amd.radeon = true; | ||||||
|       isAmdGpu = true; |       intel = { | ||||||
|  |         cpu = true; | ||||||
|  |         iGpu = true; | ||||||
|  |       }; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     boot = { |     boot = { | ||||||
|  |  | ||||||
|  | @ -2,8 +2,10 @@ | ||||||
|   config = { |   config = { | ||||||
|     my.hardware = { |     my.hardware = { | ||||||
|       enableCommonDesktopSettings = true; |       enableCommonDesktopSettings = true; | ||||||
|       isAmdCpu = true; |       amd = { | ||||||
|       isAmdGpu = true; |         cpu = true; | ||||||
|  |         gpu = true; | ||||||
|  |       }; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     boot = { |     boot = { | ||||||
|  |  | ||||||
|  | @ -1,6 +1,28 @@ | ||||||
| {...}: { | { | ||||||
|  |   config, | ||||||
|  |   lib, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   unstable-commit-sha = "f5892ddac112a1e9b3612c39af1b72987ee5783a"; | ||||||
|  | in { | ||||||
|  |   options.my.allowUnfreePackages = lib.mkOption { | ||||||
|  |     type = lib.types.listOf lib.types.str; | ||||||
|  |     default = []; | ||||||
|  |     example = ["steam"]; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|   config = { |   config = { | ||||||
|     nixpkgs.config.allowUnfree = true; |     nixpkgs.config = { | ||||||
|  |       # make nixos-unstable availiable as 'pkgs.unstable' | ||||||
|  |       packageOverrides = pkgs: { | ||||||
|  |         unstable = import (fetchTarball "https://github.com/nixos/nixpkgs/tarball/${unstable-commit-sha}") { | ||||||
|  |           config = config.nixpkgs.config; | ||||||
|  |         }; | ||||||
|  |       }; | ||||||
|  | 
 | ||||||
|  |       # https://github.com/NixOS/nixpkgs/issues/197325#issuecomment-1579420085 | ||||||
|  |       allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.my.allowUnfreePackages; | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     system = { |     system = { | ||||||
|       stateVersion = "22.11"; |       stateVersion = "22.11"; | ||||||
|  |  | ||||||
|  | @ -12,8 +12,6 @@ | ||||||
|   programs = { |   programs = { | ||||||
|     home-manager.enable = true; |     home-manager.enable = true; | ||||||
| 
 | 
 | ||||||
|     firefox.enable = true; |  | ||||||
| 
 |  | ||||||
|     zsh = { |     zsh = { | ||||||
|       history = { |       history = { | ||||||
|         size = 10000; |         size = 10000; | ||||||
|  |  | ||||||
|  | @ -30,7 +30,6 @@ | ||||||
|   programs = { |   programs = { | ||||||
|     home-manager.enable = true; |     home-manager.enable = true; | ||||||
| 
 | 
 | ||||||
|     firefox.enable = true; |  | ||||||
|     fzf.enable = true; |     fzf.enable = true; | ||||||
|     mangohud.enable = true; |     mangohud.enable = true; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,5 +17,10 @@ | ||||||
| 
 | 
 | ||||||
|     # flatpak xdg-portal-kde crashes, otherwise this would be global |     # flatpak xdg-portal-kde crashes, otherwise this would be global | ||||||
|     services.flatpak.enable = true; |     services.flatpak.enable = true; | ||||||
|  | 
 | ||||||
|  |     # force rendering on dedicated graphics | ||||||
|  |     environment.sessionVariables = rec { | ||||||
|  |       DRI_PRIME = "1"; | ||||||
|  |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| {pkgs, ...}: { | {...}: { | ||||||
|   imports = [ |   imports = [ | ||||||
|     (import ./modules { |     (import ./modules { | ||||||
|       hostName = "vinzenz-pc2"; |       hostName = "vinzenz-pc2"; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter