nix machine / user configurations
at terra 3.7 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 inputs, 6 ... 7}: 8let 9 btrfsPartPath = "/dev/disk/by-label/NIXOS"; 10 btrfsOptions = [ 11 "compress-force=zstd" 12 "noatime" 13 ]; 14in 15{ 16 imports = 17 with inputs; 18 with nixos-hardware.nixosModules; 19 [ 20 nixpkgs.nixosModules.notDetected 21 nixos-persistence.nixosModule 22 common-pc-ssd 23 common-pc 24 common-gpu-amd 25 common-cpu-amd 26 ../../modules/persist 27 ../../modules/network 28 #../../modules/develop/nixbuild 29 ../../users/root 30 ../../users/patriot 31 ]; 32 33 system.persistDir = "/persist"; 34 35 boot = { 36 tmpOnTmpfs = true; 37 loader = { 38 efi.canTouchEfiVariables = true; 39 systemd-boot.enable = true; 40 systemd-boot.configurationLimit = 10; 41 }; 42 kernelPackages = pkgs.linuxPackages_latest; 43 supportedFilesystems = [ "btrfs" ]; 44 initrd = { 45 availableKernelModules = [ 46 "xhci_pci" 47 "ahci" 48 "usb_storage" 49 "usbhid" 50 "sd_mod" 51 ]; 52 kernelModules = [ "amdgpu" ]; 53 }; 54 kernelModules = [ "kvm-amd" ]; 55 extraModulePackages = [ ]; 56 kernel.sysctl = { 57 "fs.inotify.max_user_watches" = 524288; 58 }; 59 }; 60 61 fileSystems."/" = { 62 device = "none"; 63 fsType = "tmpfs"; 64 options = [ 65 "defaults" 66 "size=2G" 67 "mode=755" 68 ]; 69 }; 70 fileSystems."/nix" = { 71 device = btrfsPartPath; 72 fsType = "btrfs"; 73 options = [ "subvol=nix" ] ++ btrfsOptions; 74 }; 75 fileSystems."${config.system.persistDir}" = { 76 device = btrfsPartPath; 77 fsType = "btrfs"; 78 options = [ "subvol=persist" ] ++ btrfsOptions; 79 neededForBoot = true; 80 }; 81 fileSystems."/boot" = { 82 device = "/dev/disk/by-label/BOOT"; 83 fsType = "vfat"; 84 }; 85 86 swapDevices = [ ]; 87 zramSwap = { 88 enable = true; 89 algorithm = "zstd"; 90 }; 91 92 nix.settings.max-jobs = lib.mkDefault 4; 93 security = { 94 pam.loginLimits = [ 95 { 96 domain = "*"; 97 type = "soft"; 98 item = "nofile"; 99 value = "524288"; 100 } 101 { 102 domain = "*"; 103 type = "hard"; 104 item = "nofile"; 105 value = "524288"; 106 } 107 ]; 108 allowSimultaneousMultithreading = false; 109 # Deleting root subvolume makes sudo show lecture every boot 110 sudo.extraConfig = '' 111 Defaults lecture = never 112 ''; 113 rtkit.enable = true; 114 }; 115 116 sound.enable = false; 117 services.pipewire = { 118 enable = true; 119 alsa.enable = true; 120 alsa.support32Bit = true; 121 pulse.enable = true; 122 }; 123 hardware = { 124 opengl = { 125 driSupport = true; 126 driSupport32Bit = true; 127 enable = true; 128 extraPackages = with pkgs; [ 129 libvdpau-va-gl 130 vaapiVdpau 131 libva 132 vulkan-loader 133 amdvlk 134 ]; 135 extraPackages32 = 136 with pkgs.pkgsi686Linux; 137 [ 138 libvdpau-va-gl 139 vaapiVdpau 140 libva 141 vulkan-loader 142 ] 143 ++ [ 144 pkgs.driversi686Linux.amdvlk 145 ]; 146 }; 147 pulseaudio = { 148 enable = false; 149 support32Bit = true; 150 }; 151 }; 152 153 fonts = { 154 enableDefaultFonts = true; 155 fontconfig.enable = true; 156 fonts = [ pkgs.dejavu_fonts ]; 157 }; 158 159 environment = { 160 systemPackages = [ pkgs.ntfs3g ]; 161 pathsToLink = [ "/share/zsh" ]; 162 persistence."${config.system.persistDir}" = { 163 directories = [ "/etc/nixos" ]; 164 files = [ "/etc/machine-id" ]; 165 }; 166 }; 167 168 networking.firewall.checkReversePath = "loose"; 169 networking.interfaces.enp6s0.useDHCP = true; 170 services = { 171 earlyoom.enable = true; 172 tailscale.enable = false; 173 ipfs = { 174 enable = false; 175 enableGC = true; 176 autoMount = true; 177 }; 178 flatpak.enable = false; 179 xserver.videoDrivers = [ "amdgpu" ]; 180 }; 181 182 system.stateVersion = "22.05"; 183}