diff --git a/flake.lock b/flake.lock index 6af0044a..808bc748 100644 --- a/flake.lock +++ b/flake.lock @@ -174,11 +174,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -194,16 +194,16 @@ ] }, "locked": { - "lastModified": 1726989464, - "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", + "lastModified": 1733951536, + "narHash": "sha256-Zb5ZCa7Xj+0gy5XVXINTSr71fCfAv+IKtmIXNrykT54=", "owner": "nix-community", "repo": "home-manager", - "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", + "rev": "1318c3f3b068cdcea922fa7c1a0a1f0c96c22f5f", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-24.05", + "ref": "release-24.11", "repo": "home-manager", "type": "github" } @@ -229,11 +229,11 @@ "nixpkgs-lib": "nixpkgs-lib_3" }, "locked": { - "lastModified": 1730486688, - "narHash": "sha256-s5yzGvmyHw3NNjHhR6Ll0sIfPxIqWVegg/Jm3Qw6y9I=", + "lastModified": 1734869532, + "narHash": "sha256-tMWJ1gDqNkCaH6jmZRXAUUhfhIrLMWJBiM+CtAtQqoY=", "owner": "nix-community", "repo": "lib-aggregate", - "rev": "dccba7ef61b0f146fbae24e1118e7b082f44d9a9", + "rev": "1451a8a6902c85c90dae3c253df5401b7eb3581f", "type": "github" }, "original": { @@ -250,11 +250,11 @@ "treefmt-nix": "treefmt-nix_3" }, "locked": { - "lastModified": 1730389079, - "narHash": "sha256-g/CJ/KKe5MGsVx1oCBl0F9aCdcNSDeOw8H7e5QDGa2c=", + "lastModified": 1733909753, + "narHash": "sha256-5GChR6LKh6EwGXLfR3HLW2Z0AWoyce4Hyp3VB5C4FCk=", "owner": "nix-community", "repo": "nix-eval-jobs", - "rev": "7f9159a16584ee86eed077c8a73e845690b7d513", + "rev": "b1f94fed4af8e7f30665a3bf8b369dc3b8a95884", "type": "github" }, "original": { @@ -294,11 +294,11 @@ ] }, "locked": { - "lastModified": 1720066371, - "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "lastModified": 1731952509, + "narHash": "sha256-p4gB3Rhw8R6Ak4eMl8pqjCPOLCZRqaehZxdZ/mbFClM=", "owner": "nix-community", "repo": "nix-github-actions", - "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", + "rev": "7b5f051df789b6b20d259924d349a9ba3319b226", "type": "github" }, "original": { @@ -460,11 +460,11 @@ }, "nixpkgs-lib_3": { "locked": { - "lastModified": 1729990941, - "narHash": "sha256-hUP9oxmnOmNnKcDOf5Y55HQ+NnoT0+bLWHLQWLLw9Ks=", + "lastModified": 1734829460, + "narHash": "sha256-dPhc+f2wkmhMqMIfq+hColJdysgVxKP9ilZ5bR0NRZI=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "7d68864343650322045894951602d6e82b5296d7", + "rev": "0a31e8d833173ae63e43fd9dbff1ccf09c4f778c", "type": "github" }, "original": { @@ -481,11 +481,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1730500345, - "narHash": "sha256-6eN2VYWB47k2wTSCCaKJLekiv1ThANA7XpJQ/hdNl5s=", + "lastModified": 1734896070, + "narHash": "sha256-HECsyS551+KtffczDgx7w/xvruXHKoUf4JX7xW+Ecbo=", "owner": "nix-community", "repo": "nixpkgs-wayland", - "rev": "966208411fe5f69346a7371d0f0499ec93693118", + "rev": "8988b0603fed7e3d303718328cf4cd8dd137575e", "type": "github" }, "original": { @@ -512,27 +512,27 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1730327045, - "narHash": "sha256-xKel5kd1AbExymxoIfQ7pgcX6hjw9jCgbiBjiUfSVJ8=", + "lastModified": 1734083684, + "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "080166c15633801df010977d9d7474b4a6c549d7", + "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.05", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_4": { "locked": { - "lastModified": 1723221148, - "narHash": "sha256-7pjpeQlZUNQ4eeVntytU3jkw9dFK3k1Htgk2iuXjaD8=", + "lastModified": 1732238832, + "narHash": "sha256-sQxuJm8rHY20xq6Ah+GwIUkF95tWjGRd1X8xF+Pkk38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "154bcb95ad51bc257c2ce4043a725de6ca700ef6", + "rev": "8edf06bea5bcbee082df1b7369ff973b91618b8d", "type": "github" }, "original": { @@ -544,11 +544,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1730200266, - "narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=", + "lastModified": 1734649271, + "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd", + "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0dbacb87..8f66d154 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { # NixOS related inputs - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; sops-nix = { @@ -35,7 +35,7 @@ # home-manager related inputs home-manager = { - url = "github:nix-community/home-manager/release-24.05"; + url = "github:nix-community/home-manager/release-24.11"; inputs.nixpkgs.follows = "nixpkgs"; }; nurpkgs.url = "github:nix-community/NUR"; @@ -89,6 +89,10 @@ }; }; + nixosModules = { + nvidia = import ./nixos-modules/nvidia; + }; + homeConfigurations = { # NixOS home configuration setup lives in # nixos-config/default.nix and their respective host-specific diff --git a/home-config/config/desktop/default.nix b/home-config/config/desktop/default.nix index d2aeab92..d354460e 100644 --- a/home-config/config/desktop/default.nix +++ b/home-config/config/desktop/default.nix @@ -1,3 +1,4 @@ +{ pkgs, ... }: { imports = [ ./dunst.nix @@ -7,6 +8,9 @@ ./sway.nix ]; + home.packages = with pkgs; [ + caffeine-ng + ]; services.caffeine.enable = true; xsession.importedVariables = [ "PATH" ]; } diff --git a/home-config/config/desktop/sway.nix b/home-config/config/desktop/sway.nix index b683dc3e..a7d92c62 100644 --- a/home-config/config/desktop/sway.nix +++ b/home-config/config/desktop/sway.nix @@ -41,6 +41,7 @@ in home.packages = [ keepassxc-copy pkgs.glib + pkgs.sway-contrib.grimshot ]; wayland.windowManager.sway = { @@ -91,6 +92,25 @@ in }; }; + programs.eww = { + enable = true; + configDir = ../../dotfiles/eww; + }; + + systemd.user.services.eww = { + Unit = { + Description = "System tray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${config.programs.eww.package}/bin/eww daemon --no-daemonize"; + ExecStartPost = "${config.programs.eww.package}/bin/eww open tray"; + }; + Install.WantedBy = [ "graphical-session.target" ]; + }; + systemd.user.services.swaylock = { Unit.Description = "Lock screen"; Service.ExecStart = "${config.programs.swaylock.package}/bin/swaylock"; diff --git a/home-config/config/xdg-settings.nix b/home-config/config/xdg-settings.nix index 8c2e0126..5fb4455d 100644 --- a/home-config/config/xdg-settings.nix +++ b/home-config/config/xdg-settings.nix @@ -36,6 +36,7 @@ in _JAVA_OPTIONS = concatStringsSep " " [ "-Djava.util.prefs.userRoot='${xdg.configHome}'/java" "-Djavafx.cachedir='${xdg.cacheHome}/openjfx'" + "-Dorg.lwjgl.glfw.libname='${pkgs.glfw-wayland-minecraft}/lib/libglfw.so'" ]; LESSKEY = "${xdg.cacheHome}/less/key"; LESSHISTFILE = "${xdg.cacheHome}/less/history"; diff --git a/home-config/dotfiles/emacs.d/config/editing.el b/home-config/dotfiles/emacs.d/config/editing.el index 5dc12ec3..f4785bd4 100644 --- a/home-config/dotfiles/emacs.d/config/editing.el +++ b/home-config/dotfiles/emacs.d/config/editing.el @@ -57,7 +57,8 @@ (leaf files :ensure nil :custom (require-final-newline . "visit-save") - :custom (major-mode-remap-alist . '((sh-mode . bash-ts-mode)))) + :custom (major-mode-remap-alist . '((sh-mode . bash-ts-mode) + (css-mode . css-ts-mode)))) ;; ---------------------------------------------------------------------------------- ;;; Snippets diff --git a/home-config/dotfiles/emacs.d/config/programming-languages.el b/home-config/dotfiles/emacs.d/config/programming-languages.el index 6b328f17..620d619b 100644 --- a/home-config/dotfiles/emacs.d/config/programming-languages.el +++ b/home-config/dotfiles/emacs.d/config/programming-languages.el @@ -223,6 +223,7 @@ ;; ---------------------------------------------------------------------------------- (leaf scss-mode + :ensure nil :mode `(,(rx (or ".sass" ".scss") string-end)) :hook (scss-mode-hook . (lambda () (setq-local devdocs-current-docs '("css" "sass"))))) @@ -245,6 +246,14 @@ string-end) . systemd-mode)) +;; ---------------------------------------------------------------------------------- +;;; Dart +;; ---------------------------------------------------------------------------------- + +(leaf dart-mode + :mode `(,(rx ".dart" string-end)) + :hook (dart-mode-hook . (lambda () (set (make-local-variable 'eglot-x-client-commands) '())))) + ;; ---------------------------------------------------------------------------------- ;;; TypeScript (and other web-related DSLs) ;; ---------------------------------------------------------------------------------- @@ -307,7 +316,8 @@ (leaf eglot :commands (eglot eglot-format eglot-managed-p) :hook (((kotlin-mode-hook web-mode-hook rust-mode-hook python-mode-hook - sh-mode-hook bash-ts-mode-hook c-mode-hook c++-mode-hook nix-mode-hook json-mode-hook) . + sh-mode-hook bash-ts-mode-hook c-mode-hook c++-mode-hook nix-mode-hook json-mode-hook + dart-mode-hook) . eglot-ensure) (eglot-managed-mode-hook . set-eldoc-compose)) :bind (:eglot-mode-map @@ -400,7 +410,10 @@ (reformatter-define latexindent :program "latexindent" :group 'latex-mode - :lighter " LF"))) + :lighter " LF") + (reformatter-define dart-format + :program "dart" + :args '("format")))) (defun autoformat () "Autoformat the current buffer." @@ -410,6 +423,8 @@ (clang-format-buffer)) ('latex-mode (latexindent-buffer)) + ('dart-mode + (dart-format-buffer)) ((or 'mhtml-mode 'web-mode 'scss-mode 'json-mode) (biome-format-buffer)) ('haskell-mode (haskell-mode-stylish-buffer)) diff --git a/home-config/dotfiles/emacs.d/share/snippets/text-mode/git-conventional-commit b/home-config/dotfiles/emacs.d/share/snippets/text-mode/git-conventional-commit new file mode 100644 index 00000000..a9631443 --- /dev/null +++ b/home-config/dotfiles/emacs.d/share/snippets/text-mode/git-conventional-commit @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: git-conventional-commit +# key: c +# condition: (git-commit-mode) +# -- +${1:type$(yas-choose-value '( "feat" "fix" "test" "chore" "refactor" "doc" "style" "release" "update" "bump" "perf" "ci"))}${2:(scope)}: ${3:Commit message} + +$0 \ No newline at end of file diff --git a/home-config/dotfiles/emacs.d/share/snippets/text-mode/git-conventional-commit-breaking b/home-config/dotfiles/emacs.d/share/snippets/text-mode/git-conventional-commit-breaking new file mode 100644 index 00000000..da096ffb --- /dev/null +++ b/home-config/dotfiles/emacs.d/share/snippets/text-mode/git-conventional-commit-breaking @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: git-conventional-commit +# key: c! +# condition: (git-commit-mode) +# -- +${1:type$(yas-choose-value '( "feat" "fix" "test" "chore" "refactor" "doc" "style" "release" "update" "bump" "perf" "ci"))}${2:(scope)}!: ${3:Commit message} + +$0 \ No newline at end of file diff --git a/home-config/dotfiles/eww/eww.scss b/home-config/dotfiles/eww/eww.scss new file mode 100644 index 00000000..716c571f --- /dev/null +++ b/home-config/dotfiles/eww/eww.scss @@ -0,0 +1,5 @@ +* { all: unset; } + +.tray-items { + font-size: 1.35em; +} diff --git a/home-config/dotfiles/eww/eww.yuck b/home-config/dotfiles/eww/eww.yuck new file mode 100644 index 00000000..74f6d40d --- /dev/null +++ b/home-config/dotfiles/eww/eww.yuck @@ -0,0 +1,49 @@ +(defwindow tray + :monitor 0 + :geometry (geometry :height "0%" + :width "0%" + :anchor "bottom left") + :stacking "bottom" + :exclusive true + :focusable false + + (_tray_items)) + +(defwidget _tray_items [] + (box :class "tray-items" + + :spacing 3 + :vexpand true + :hexpand true + :valign "center" + :halign "start" + :space-evenly false + + (_battery_icon) + (_clock) + "|" + (systray :spacing 5 + :orientation "horizontal" + :space-evenly false))) + +(defwidget _battery_icon [] + (label :text { + EWW_BATTERY == "" ? "" : + jq(EWW_BATTERY, "first(.[])").status == "Charging" ? + "" : + jq(EWW_BATTERY, "first(.[])").capacity > 75 ? + "" : + jq(EWW_BATTERY, "first(.[])").capacity > 50 ? + "" : + jq(EWW_BATTERY, "first(.[])").capacity > 25 ? + "" : + jq(EWW_BATTERY, "first(.[])").capacity > 5 ? + "" : + "" + } + :visible {EWW_BATTERY != ""} + :tooltip "${EWW_BATTERY == "" ? "" : jq(EWW_BATTERY, "first(.[])").capacity}%")) + +(defwidget _clock [] + (label :text { formattime(EWW_TIME, "%R") } + :tooltip { formattime(EWW_TIME, "%F") })) diff --git a/home-config/dotfiles/sway.conf b/home-config/dotfiles/sway.conf index 488a727b..7ca67c17 100644 --- a/home-config/dotfiles/sway.conf +++ b/home-config/dotfiles/sway.conf @@ -34,6 +34,17 @@ bindsym { ## Window/desktop management floating_modifier $mod +bindsym { + $mod+G mode "screenshot" +} + +mode "screenshot" { + bindsym Escape mode "default" + bindsym c exec grimshot copy active; mode "default" + bindsym r exec grimshot copy area; mode "default" + bindsym a exec grimshot copy output; mode "default" +} + bindsym { $mod+Up focus up $mod+Right focus right @@ -70,6 +81,9 @@ bindsym { $mod+Shift+8 move container to workspace 8; workspace 8 $mod+Shift+9 move container to workspace 9; workspace 9 $mod+Shift+0 move container to workspace 10; workspace 10 + + $mod+Shift+Left move workspace to output left + $mod+Shift+Right move workspace to output right } ## Idle inhibitors diff --git a/home-config/hosts/rin.nix b/home-config/hosts/rin.nix index ba5f5b99..12adfcf8 100644 --- a/home-config/hosts/rin.nix +++ b/home-config/hosts/rin.nix @@ -10,4 +10,9 @@ ../config/work/famedly.nix ]; + + # Adaptive sync doesn't work on rin + wayland.windowManager.sway.extraConfig = '' + output "*" adaptive_sync off + ''; } diff --git a/home-modules/firefox-webapp.nix b/home-modules/firefox-webapp.nix index a34dc8c6..561a0c1c 100644 --- a/home-modules/firefox-webapp.nix +++ b/home-modules/firefox-webapp.nix @@ -66,6 +66,8 @@ let system = 2; }; }; + + extensions = cfg.extensions; } ) cfg; in @@ -104,6 +106,12 @@ in description = "Additional Firefox profile settings."; }; + extensions = mkOption { + type = listOf package; + default = [ ]; + description = "Additional Firefox profile extensions."; + }; + backgroundColor = mkOption { type = str; default = "rgba(0, 0, 0, 0)"; diff --git a/nixos-config/default.nix b/nixos-config/default.nix index 89440123..287ef9b4 100644 --- a/nixos-config/default.nix +++ b/nixos-config/default.nix @@ -1,11 +1,14 @@ { config, pkgs, + lib, flake-inputs, ... }: { imports = [ + flake-inputs.self.nixosModules.nvidia + flake-inputs.home-manager.nixosModules.home-manager flake-inputs.sops-nix.nixosModules.sops @@ -17,8 +20,6 @@ ]; nix = { - package = pkgs.nixFlakes; - settings = { auto-optimise-store = true; experimental-features = [ @@ -54,7 +55,10 @@ boot = { tmp.cleanOnBoot = true; plymouth.enable = true; - kernelPackages = pkgs.linuxKernel.packages.linux_xanmod_latest; + kernelPackages = lib.mkMerge [ + (lib.mkIf config.easyNvidia.enable pkgs.linuxKernel.packages.linux_xanmod) + (lib.mkIf (!config.easyNvidia.enable) pkgs.linuxKernel.packages.linux_xanmod_latest) + ]; loader = { timeout = 0; @@ -68,7 +72,9 @@ }; }; - time.timeZone = "Europe/Amsterdam"; + time.timeZone = lib.mkDefault "Asia/Hong_Kong"; + services.automatic-timezoned.enable = true; + services.geoclue2.geoProviderUrl = "https://api.beacondb.net/v1/geolocate"; users = { defaultUserShell = pkgs.zsh; @@ -107,6 +113,7 @@ git.enable = true; zsh.enable = true; nano.enable = false; + firefox.enable = true; }; security.sudo-rs.enable = true; @@ -119,7 +126,7 @@ packages = with pkgs; [ hack-font noto-fonts - noto-fonts-cjk + noto-fonts-cjk-sans noto-fonts-emoji ]; diff --git a/nixos-config/hosts/rin/default.nix b/nixos-config/hosts/rin/default.nix index b0c200db..dbaf8042 100644 --- a/nixos-config/hosts/rin/default.nix +++ b/nixos-config/hosts/rin/default.nix @@ -23,6 +23,23 @@ sops.age.keyFile = "/var/lib/sops/host.age"; + nixpkgs.config.allowUnfreePredicate = + pkg: + builtins.elem (pkgs.lib.getName pkg) [ + "nvidia-x11" + "nvidia-settings" + ]; + + easyNvidia = { + enable = true; + withIntegratedGPU = true; + }; + + hardware.nvidia.prime = { + nvidiaBusId = "PCI:1:0:0"; + amdgpuBusId = "PCI:C5:0:0"; + }; + networking = { hostName = "rin"; hostId = "e6aaf496"; diff --git a/nixos-config/hosts/yui/default.nix b/nixos-config/hosts/yui/default.nix index 688b3186..e217349f 100644 --- a/nixos-config/hosts/yui/default.nix +++ b/nixos-config/hosts/yui/default.nix @@ -13,14 +13,12 @@ in flake-inputs.nixos-hardware.nixosModules.common-pc flake-inputs.nixos-hardware.nixosModules.common-pc-ssd flake-inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate - flake-inputs.nixos-hardware.nixosModules.common-gpu-nvidia-nonprime ./games.nix ./hardware-configuration.nix ../../networking/personal.nix ./wireguard.nix ../../wireguard.nix - ./nvidia ./networking.nix ]; @@ -31,9 +29,9 @@ in "steam-run" # Required to get the steam controller to work (i.e., for hardware.steam-hardware) "steam-original" + "steam-unwrapped" "nvidia-x11" "nvidia-settings" - "nvidia-persistenced" ]; home-manager.users.tlater = import "${flake-inputs.self}/home-config/hosts/yui.nix"; @@ -43,6 +41,12 @@ in sshKeyPaths = [ ]; }; + easyNvidia = { + enable = true; + withIntegratedGPU = false; + vaapi.firefox.av1Support = true; + }; + boot = { blacklistedKernelModules = [ # Used for IPMI (remote maintenance thing), but is unsupported diff --git a/nixos-config/hosts/yui/nvidia/default.nix b/nixos-config/hosts/yui/nvidia/default.nix deleted file mode 100644 index 0e7205a4..00000000 --- a/nixos-config/hosts/yui/nvidia/default.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - pkgs, - flake-inputs, - config, - lib, - ... -}: -{ - imports = [ ./vaapi.nix ]; - - hardware.nvidia = { - package = config.boot.kernelPackages.nvidiaPackages.mkDriver { - version = "565.57.01"; - sha256_64bit = "sha256-buvpTlheOF6IBPWnQVLfQUiHv4GcwhvZW3Ks0PsYLHo="; - sha256_aarch64 = lib.fakeHash; - openSha256 = "sha256-/tM3n9huz1MTE6KKtTCBglBMBGGL/GOHi5ZSUag4zXA="; - settingsSha256 = lib.fakeHash; - persistencedSha256 = lib.fakeHash; - }; - - # The nvidia-settings build is currently broken due to a missing - # vulkan header; re-enable whenever - # 0384602eac8bc57add3227688ec242667df3ffe3the hits stable. - nvidiaSettings = false; - - modesetting.enable = true; - # Power management is required to get nvidia GPUs to behave on - # suspend, due to firmware bugs. Aren't nvidia great? - powerManagement.enable = true; - open = true; - - vaapi = { - enable = true; - firefox.enable = true; - }; - }; - - programs.sway.package = pkgs.sway.override { - inherit (flake-inputs.nixpkgs-wayland.packages.${pkgs.system}) sway-unwrapped; - }; - - boot = { - kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_xanmod; - kernelParams = [ "nvidia-drm.fbdev=1" ]; - - extraModprobeConfig = - "options nvidia " - + lib.concatStringsSep " " [ - # nvidia assume that by default your CPU does not support PAT, - # but this is effectively never the case in 2023 - "NVreg_UsePageAttributeTable=1" - # This is sometimes needed for ddc/ci support, see - # https://www.ddcutil.com/nvidia/ - # - # Current monitor does not support it, but this is useful for - # the future - "NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100" - ]; - }; - - environment.variables = { - # Required to run the correct GBM backend for nvidia GPUs on wayland - GBM_BACKEND = "nvidia-drm"; - # Apparently, without this nouveau may attempt to be used instead - # (despite it being blacklisted) - __GLX_VENDOR_LIBRARY_NAME = "nvidia"; - # Hardware cursors are currently broken on nvidia - WLR_NO_HARDWARE_CURSORS = "1"; - }; -} diff --git a/nixos-config/hosts/yui/nvidia/vaapi.nix b/nixos-config/hosts/yui/nvidia/vaapi.nix deleted file mode 100644 index 3d9d985e..00000000 --- a/nixos-config/hosts/yui/nvidia/vaapi.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.hardware.nvidia.vaapi; -in -{ - options.hardware.nvidia.vaapi = with lib.types; { - enable = lib.mkEnableOption "vaapi"; - - maxInstances = lib.mkOption { - type = nullOr int; - default = null; - description = '' - The maximum number of concurrent instances of the driver. - - Sometimes useful for graphics cards with little VRAM. - ''; - }; - - firefox = { - enable = lib.mkEnableOption "Firefox configuration"; - - av1Support = lib.mkOption { - type = bool; - default = false; - description = "Whether to enable av1 support. Should be disabled for GeForce 20 and earlier."; - }; - }; - }; - - # See https://github.com/elFarto/nvidia-vaapi-driver#configuration - config = lib.mkIf cfg.enable { - environment.variables = - { - NVD_BACKEND = "direct"; - } - // lib.optionalAttrs (cfg.maxInstances != null) { NVD_MAX_INSTANCES = toString cfg.maxInstances; } - // lib.optionalAttrs cfg.firefox.enable { MOZ_DISABLE_RDD_SANDBOX = "1"; }; - - # TODO(tlater): Find a way to properly integrate this so we can - # upstream it. - home-manager.users.tlater.programs.firefox.profiles.tlater.settings = lib.mkIf cfg.firefox.enable { - "media.ffmpeg.vaapi.enabled" = true; - "media.rdd-ffmpeg.enabled" = true; - "media.av1.enabled" = cfg.firefox.av1Support; - "gfx.x11-egl.force-enabled" = true; - "widget.dmabuf.force-enabled" = true; - }; - }; -} diff --git a/nixos-config/sway.nix b/nixos-config/sway.nix index fc8cc565..d456eadb 100644 --- a/nixos-config/sway.nix +++ b/nixos-config/sway.nix @@ -1,10 +1,22 @@ -{ pkgs, ... }: +{ + pkgs, + lib, + config, + flake-inputs, + ... +}: { environment.systemPackages = with pkgs; [ bibata-cursors ]; programs.sway = { enable = true; wrapperFeatures.gtk = true; + + package = lib.mkIf config.easyNvidia.enable ( + pkgs.sway.override { + inherit (flake-inputs.nixpkgs-wayland.packages.${pkgs.system}) sway-unwrapped; + } + ); }; xdg.portal = { diff --git a/nixos-modules/nvidia/default.nix b/nixos-modules/nvidia/default.nix new file mode 100644 index 00000000..b4e7aba8 --- /dev/null +++ b/nixos-modules/nvidia/default.nix @@ -0,0 +1,81 @@ +{ + pkgs, + config, + lib, + ... +}: +let + cfg = config.easyNvidia; +in +{ + imports = [ ./vaapi.nix ]; + + options.easyNvidia = with lib.types; { + enable = lib.mkEnableOption "easyNvidia"; + withIntegratedGPU = lib.mkOption { + type = bool; + description = '' + Whether the computer has a separate integrated GPU. + + This also configures the machine to use the integrated GPU for + other things like software decoding, so keep this enabled even + if you separately disable offload rendering. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.mkDriver { + version = "565.77"; + sha256_64bit = "sha256-CnqnQsRrzzTXZpgkAtF7PbH9s7wbiTRNcM0SPByzFHw="; + sha256_aarch64 = lib.fakeHash; + openSha256 = "sha256-Fxo0t61KQDs71YA8u7arY+503wkAc1foaa51vi2Pl5I="; + settingsSha256 = "sha256-VUetj3LlOSz/LB+DDfMCN34uA4bNTTpjDrb6C6Iwukk="; + persistencedSha256 = lib.fakeHash; + }; + + # This will no longer be necessary when + # https://github.com/NixOS/nixpkgs/pull/326369 hits stable + modesetting.enable = lib.mkDefault true; + # Power management is nearly always required to get nvidia GPUs to + # behave on suspend, due to firmware bugs. + powerManagement.enable = true; + # The open driver is recommended by nvidia now, see + # https://download.nvidia.com/XFree86/Linux-x86_64/565.57.01/README/kernel_open.html + open = true; + + dynamicBoost.enable = cfg.withIntegratedGPU; + }; + + boot = { + kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_xanmod; + + extraModprobeConfig = + "options nvidia " + + lib.concatStringsSep " " [ + # nvidia assume that by default your CPU does not support PAT, + # but this is effectively never the case in 2023 + "NVreg_UsePageAttributeTable=1" + # This is sometimes needed for ddc/ci support, see + # https://www.ddcutil.com/nvidia/ + # + # Current monitor does not support it, but this is useful for + # the future + "NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100" + ]; + }; + + environment.variables = { + # Required to run the correct GBM backend for nvidia GPUs on wayland + GBM_BACKEND = "nvidia-drm"; + # Apparently, without this nouveau may attempt to be used instead + # (despite it being blacklisted) + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + # Hardware cursors are currently broken on wlroots + WLR_NO_HARDWARE_CURSORS = "1"; + }; + }; +} diff --git a/nixos-modules/nvidia/prime.nix b/nixos-modules/nvidia/prime.nix new file mode 100644 index 00000000..ff4626bd --- /dev/null +++ b/nixos-modules/nvidia/prime.nix @@ -0,0 +1,36 @@ +{ + pkgs, + config, + lib, + ... +}: +let + cfg = config.easyNvidia.prime; +in +{ + options.easyNvidia.offload = with lib.types; { + enable = lib.mkOption { + type = bool; + enable = config.easyNvidia.prime.withIntegratedGPU; + description = '' + Whether to configure prime offload. + + This will allow on-demand offloading of rendering tasks to the + NVIDIA GPU, all other rendering will happen on the GPU + integrated in the CPU. + + The GPU *should* be turned off whenever it is not in use, so + this shouldn't cause increased battery drain, but there are + some reports floating around that this isn't always the case - + likely especially for older devices. Feel free to turn it off + if you find this doesn't work properly for you. + + ''; + }; + }; + + config = lib.mkIf cfg.easyNvidia.offload.enable { + hardware.nvidia.prime.offload.enable = true; + hardware.nvidia.powerManagement.finegrained = true; + }; +} diff --git a/nixos-modules/nvidia/vaapi.nix b/nixos-modules/nvidia/vaapi.nix new file mode 100644 index 00000000..6e8851ac --- /dev/null +++ b/nixos-modules/nvidia/vaapi.nix @@ -0,0 +1,93 @@ +{ + pkgs, + config, + lib, + ... +}: +let + cfg = config.easyNvidia.vaapi; +in +{ + options.easyNvidia.vaapi = with lib.types; { + enable = lib.mkOption { + type = bool; + default = !config.easyNvidia.withIntegratedGPU; + description = '' + Whether to enable the NVIDIA vaapi driver. + + This allows using the NVIDIA GPU for decoding video streams + instead of using software decoding on the CPU. + + This particularly makes sense for desktop computers without an + iGPU, as on those software en/decoding will take a lot of + processing power while the NVIDIA GPU's encoding capacity + isn't doing anything, so this option is enabled by default + there. + + However, on machines with an iGPU, the dGPU's en/decoding + capabilities are often more limited than those of the iGPU, + and require more power, so this is disabled there by default - + it may still make sense from time to time, so feel free to + experiment. + + ''; + + }; + + maxInstances = lib.mkOption { + type = nullOr int; + default = null; + description = '' + The maximum number of concurrent instances of the driver. + + Sometimes useful for graphics cards with little VRAM. + ''; + }; + + firefox = { + enable = lib.mkOption { + type = bool; + default = config.programs.firefox.enable; + description = '' + Configure Firefox to used the vaapi driver for video decoding. + + Note that this requires disabling the [RDD + sandbox](https://firefox-source-docs.mozilla.org/dom/ipc/process_model.html#data-decoder-rdd-process). + ''; + }; + + av1Support = lib.mkOption { + type = bool; + default = false; + description = '' + Whether to enable av1 support. + + This will not work on Turing (e.g. Geforce 2xxx) and + earlier, and is therefore disabled by default there. + ''; + }; + }; + }; + + # See https://github.com/elFarto/nvidia-vaapi-driver#configuration + config = lib.mkIf cfg.enable { + environment = { + systemPackages = [ pkgs.libva-utils ]; + variables = + { + NVD_BACKEND = "direct"; + LIBVA_DRIVER_NAME = "nvidia"; + } + // lib.optionalAttrs (cfg.maxInstances != null) { NVD_MAX_INSTANCES = toString cfg.maxInstances; } + // lib.optionalAttrs cfg.firefox.enable { MOZ_DISABLE_RDD_SANDBOX = "1"; }; + }; + + programs.firefox.preferences = lib.mkIf cfg.firefox.enable { + "media.ffmpeg.vaapi.enabled" = true; + "media.rdd-ffmpeg.enabled" = true; + "media.av1.enabled" = cfg.firefox.av1Support; + "gfx.x11-egl.force-enabled" = true; + "widget.dmabuf.force-enabled" = true; + }; + }; +} diff --git a/pkgs/applications/emacs/default.nix b/pkgs/applications/emacs/default.nix index ddb3c485..a7bd73eb 100644 --- a/pkgs/applications/emacs/default.nix +++ b/pkgs/applications/emacs/default.nix @@ -4,11 +4,11 @@ hostPlatform, emacsPackagesFor, emacsMacport, - emacs29, + emacs29-pgtk, runCommandLocal, }: let - emacsPlatform = if hostPlatform.isDarwin then emacsMacport else emacs29; + emacsPlatform = if hostPlatform.isDarwin then emacsMacport else emacs29-pgtk; overrides = self: _super: { eglot-x = self.callPackage ./eglot-x.nix { inherit sources; }; }; @@ -32,6 +32,7 @@ let (epkgs.treesit-grammars.with-grammars ( grammars: with grammars; [ tree-sitter-bash + tree-sitter-css tree-sitter-typescript tree-sitter-tsx ] diff --git a/pkgs/applications/nextcloudcmd.nix b/pkgs/applications/nextcloudcmd.nix index 269a3d1c..0f4bcdc8 100644 --- a/pkgs/applications/nextcloudcmd.nix +++ b/pkgs/applications/nextcloudcmd.nix @@ -1,7 +1,7 @@ { nextcloud-client, stdenv, - libsForQt5, + kdePackages, cmake, pkg-config, openssl, @@ -14,17 +14,18 @@ stdenv.mkDerivation { nativeBuildInputs = [ cmake pkg-config - libsForQt5.wrapQtAppsHook + kdePackages.wrapQtAppsHook ]; buildInputs = [ openssl zlib - libsForQt5.qtbase - libsForQt5.qtkeychain - libsForQt5.qtwebsockets - libsForQt5.qtwebengine - libsForQt5.karchive + kdePackages.qtbase + kdePackages.qtkeychain + kdePackages.qtwebsockets + kdePackages.qtsvg + kdePackages.qt5compat + kdePackages.karchive ]; cmakeFlags = [ @@ -32,5 +33,6 @@ stdenv.mkDerivation { "-DBUILD_UPDATER=off" "-DBUILD_GUI=off" "-DBUILD_SHELL_INTEGRATION=off" + "-DBUILD_WITH_WEBENGINE=off" ]; }