configuration.nix 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. {
  2. config,
  3. pkgs,
  4. lib,
  5. inputs,
  6. system,
  7. ...
  8. }: {
  9. imports = [
  10. ./hardware-configuration.nix
  11. ./persist.nix
  12. # Shared Configuration
  13. ../shared/configuration.nix
  14. ];
  15. sops = {
  16. defaultSopsFile = ./secrets.yaml;
  17. age.sshKeyPaths = ["/home/ludovico/.ssh/id_ed25519" "/home/ludovico/.ssh/id_rsa"];
  18. secrets.ludovico.neededForUsers = true;
  19. secrets.root.neededForUsers = true;
  20. secrets.wireguardPrivateKey = {
  21. inherit (config.users.users.systemd-network) group;
  22. reloadUnits = ["systemd-networkd.service"];
  23. mode = "0640";
  24. };
  25. secrets.wireguardPresharedKey = {
  26. inherit (config.users.users.systemd-network) group;
  27. reloadUnits = ["systemd-networkd.service"];
  28. mode = "0640";
  29. };
  30. };
  31. users = {
  32. mutableUsers = false;
  33. users.root.passwordFile = config.sops.secrets.root.path;
  34. users.ludovico = {
  35. passwordFile = config.sops.secrets.ludovico.path;
  36. isNormalUser = true;
  37. home = "/home/ludovico";
  38. shell = pkgs.fish;
  39. extraGroups =
  40. [
  41. "wheel"
  42. "video"
  43. "audio"
  44. "realtime"
  45. ]
  46. ++ pkgs.lib.optional config.virtualisation.libvirtd.enable "libvirtd"
  47. ++ pkgs.lib.optional config.virtualisation.docker.enable "docker"
  48. ++ pkgs.lib.optional config.networking.networkmanager.enable "networkmanager";
  49. };
  50. };
  51. # An anime game launcher
  52. programs = {
  53. anime-game-launcher.enable = true;
  54. anime-borb-launcher.enable = true;
  55. honkers-railway-launcher.enable = true;
  56. };
  57. boot = {
  58. loader.systemd-boot.enable = true;
  59. loader.systemd-boot.configurationLimit = 5;
  60. loader.efi.canTouchEfiVariables = true;
  61. loader.efi.efiSysMountPoint = "/boot";
  62. kernelPackages = pkgs.linuxPackages_xanmod_latest;
  63. supportedFilesystems = ["ntfs" "btrfs"];
  64. };
  65. hardware.bluetooth.enable = true;
  66. # OpenGL
  67. environment.variables.AMD_VULKAN_ICD = lib.mkDefault "RADV"; # AMDVLK or RADV
  68. boot = {
  69. initrd.kernelModules = ["amdgpu"];
  70. kernelParams = ["amd_pstate=passive" "initcall_blacklist=acpi_cpufreq_init"];
  71. # kernelModules = ["amd-pstate"];
  72. };
  73. hardware = {
  74. enableRedistributableFirmware = true;
  75. cpu.amd.updateMicrocode = true;
  76. opengl = {
  77. enable = true;
  78. driSupport = true;
  79. driSupport32Bit = true;
  80. extraPackages = with pkgs; [
  81. # amdvlk
  82. rocm-opencl-icd
  83. rocm-opencl-runtime
  84. ];
  85. # extraPackages32 = with pkgs; [driversi686Linux.amdvlk];
  86. };
  87. };
  88. virtualisation.libvirtd.enable = true; # Qemu
  89. environment.systemPackages = lib.attrValues {
  90. inherit
  91. (pkgs)
  92. authy
  93. discord-canary
  94. exa
  95. firefox
  96. fzf
  97. gamescope
  98. lutris
  99. mailspring
  100. mangohud
  101. ripgrep
  102. steam
  103. tdesktop
  104. webcord-vencord
  105. virt-manager
  106. virt-viewer
  107. qemu
  108. OVMF
  109. gvfs
  110. qbittorrent
  111. /*
  112. Audio & Video
  113. */
  114. mpv
  115. kdenlive # Video Editor
  116. gimp
  117. mediainfo
  118. glaxnimate
  119. ;
  120. inherit
  121. (inputs.nixpkgs-wayland.packages.${system})
  122. grim
  123. slurp
  124. wf-recorder
  125. wl-clipboard
  126. wlogout
  127. ;
  128. inherit (inputs.self.packages.${system}) koneko;
  129. inherit (pkgs.qt6) qtwayland;
  130. inherit (inputs.nil.packages.${system}) default;
  131. inherit (inputs.hyprland-contrib.packages.${system}) grimblast;
  132. # use OCR and copy to clipboard
  133. ocrScript = let
  134. inherit (pkgs) grim libnotify slurp tesseract5 wl-clipboard;
  135. _ = lib.getExe;
  136. in
  137. pkgs.writers.writeDashBin "wl-ocr" ''
  138. ${_ grim} -g "$(${_ slurp})" -t ppm - | ${_ tesseract5} - - | ${wl-clipboard}/bin/wl-copy
  139. ${_ libnotify} "$(${wl-clipboard}/bin/wl-paste)"
  140. '';
  141. };
  142. programs = {
  143. gamemode = {
  144. enable = true;
  145. settings = {
  146. custom = {
  147. start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
  148. end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
  149. };
  150. };
  151. };
  152. fish.enable = true;
  153. hyprland.enable = true;
  154. };
  155. # unlock GPG keyring on login
  156. security = {
  157. pam.services.greetd.gnupg.enable = true;
  158. pam.services.greetd.enableGnomeKeyring = true;
  159. pam.services.swaylock.text = "auth include login";
  160. };
  161. environment.etc."greetd/environments".text = ''
  162. Hyprland
  163. sway
  164. fish
  165. '';
  166. # TLP For Laptop
  167. services = {
  168. gvfs.enable = true;
  169. tlp.enable = true;
  170. tlp.settings = {
  171. CPU_SCALING_GOVERNOR_ON_AC = "performance";
  172. CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
  173. RADEON_DPM_STATE_ON_AC = "performance";
  174. RADEON_DPM_STATE_ON_BAT = "battery";
  175. # https://linrunner.de/en/tlp/docs/tlp-faq.html#battery
  176. # use "tlp fullcharge" to override temporarily
  177. START_CHARGE_THRESH_BAT0 = 85;
  178. STOP_CHARGE_THRESH_BAT0 = 90;
  179. START_CHARGE_THRESH_BAT1 = 85;
  180. STOP_CHARGE_THRESH_BAT1 = 90;
  181. SOUND_POWER_SAVE_ON_AC = 0;
  182. };
  183. greetd = let
  184. user = "ludovico";
  185. greetd = "${pkgs.greetd.greetd}/bin/greetd";
  186. gtkgreet = "${pkgs.greetd.gtkgreet}/bin/gtkgreet";
  187. sway-kiosk = command: "${pkgs.sway}/bin/sway --config ${pkgs.writeText "kiosk.config" ''
  188. output * bg #000000 solid_color
  189. exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
  190. exec "${command}; ${pkgs.sway}/bin/swaymsg exit"
  191. ''}";
  192. in {
  193. enable = true;
  194. vt = 7;
  195. settings = {
  196. default_session = {
  197. command = sway-kiosk "${gtkgreet} -l -c 'Hyprland'";
  198. inherit user;
  199. };
  200. };
  201. };
  202. xserver = {
  203. enable = true;
  204. layout = "us"; # Configure keymap
  205. libinput.enable = true;
  206. deviceSection = ''
  207. Option "TearFree" "true"
  208. '';
  209. displayManager = {
  210. lightdm.enable = false;
  211. };
  212. };
  213. };
  214. xdg.portal = {
  215. enable = true;
  216. wlr.enable = lib.mkForce false;
  217. extraPortals = with pkgs;
  218. with inputs; [
  219. xdg-desktop-portal-gtk
  220. # xdph.packages.${pkgs.system}.default
  221. ];
  222. };
  223. networking.wg-quick.interfaces = {
  224. wg0 = {
  225. autostart = true;
  226. address = ["10.66.66.3/32" "fd42:42:42::3/128"];
  227. dns = ["103.235.73.71"];
  228. privateKeyFile = config.sops.secrets.wireguardPrivateKey.path;
  229. peers = [
  230. {
  231. publicKey = "6c2tFt3lF9+/UiSuxwrKBypON0U2y7wYGn9DWEBmi2A=";
  232. presharedKeyFile = config.sops.secrets.wireguardPresharedKey.path;
  233. allowedIPs = ["0.0.0.0/0" "::/0"];
  234. endpoint = "103.235.73.71:50935";
  235. persistentKeepalive = 25;
  236. }
  237. ];
  238. };
  239. };
  240. # Remove Bloat
  241. documentation.doc.enable = lib.mkForce false;
  242. }