feat: add nixGL module

This commit is contained in:
Leon Schwarzäugl 2025-03-22 22:35:38 +01:00
parent 9c1df052a2
commit faff8d9ee6
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
5 changed files with 62 additions and 3 deletions

View file

@ -3985,6 +3985,12 @@ Laptops are not always plugged in, so they should show a battery icon in Waybar.
This section is mostly used to deliver the correct information to Waybar. AMD systems have changing hwmon paths that can be specifically set here. Also the cpu count can be set here for Waybars cpu module, but 8 is usually a good setting to show
to get the info for the secondary gpu, use `lspci -nn | grep VGA`
It can be set to either:
- a number, selecting the n-th non-default GPU
- a PCI bus id in the form =pci-XXX_YY_ZZ_U=
- a PCI id in the form =vendor_id:device_id=
#+begin_src nix :tangle modules/home/hardware.nix
{ lib, ... }:
{
@ -3993,6 +3999,11 @@ This section is mostly used to deliver the correct information to Waybar. AMD sy
type = lib.types.int;
default = 8;
};
isSecondaryGpu = lib.mkEnableOption "device has a secondary GPU";
SecondaryGpuCard = lib.mkOption {
type = lib.types.str;
default = "";
};
temperatureHwmon = {
isAbsolutePath = lib.mkEnableOption "absolute temperature path";
path = lib.mkOption {
@ -4962,7 +4973,7 @@ This sets up the =nix-secrets= extraSpeciaArgs. This should not be present on th
{ inputs, config, lib, ... }:
{
home-manager = lib.mkIf config.swarselsystems.withHomeManager {
extraSpecialArgs = { inherit (inputs) nix-secrets; };
extraSpecialArgs = { inherit (inputs) nix-secrets nixgl; };
};
}
#+end_src
@ -8585,6 +8596,33 @@ Again, we adapt =nix= to our needs, enable the home-manager command for non-NixO
}
#+end_src
**** nixGL
:PROPERTIES:
:CUSTOM_ID: h:90af1862-90b3-4c93-8730-2443bc62986a
:END:
This integrates nixGL into home-manager. NixGL provies OpenGL and Vulkan APIs to nix installed utilities. This is needed for graphical applications on non-NixOS systems.
#+begin_src nix :tangle profiles/home/common/nixgl.nix
{ lib, config, nixgl, ... }:
{
nixGL = lib.mkIf (!config.swarselsystems.isNixos) {
inherit (nixgl) packages;
defaultWrapper = lib.mkDefault "mesa";
vulkan.enable = lib.mkDefault false;
prime = lib.mkIf config.swarselsystem.isSecondaryGpu {
card = config.swarselsystem.secondaryGpuCard;
installScript = "mesa";
};
offloadWrapper = lib.mkIf config.swarselsystem.isSecondaryGpu "mesaPrime";
installScripts = [
"mesa"
"mesaPrime"
];
};
}
#+end_src
**** Installed packages
:PROPERTIES:
:CUSTOM_ID: h:893a7f33-7715-415b-a895-2687ded31c18

View file

@ -95,7 +95,6 @@
in
{
inherit lib;
nixosModules = import ./modules/nixos { inherit lib; };

View file

@ -5,6 +5,11 @@
type = lib.types.int;
default = 8;
};
isSecondaryGpu = lib.mkEnableOption "device has a secondary GPU";
SecondaryGpuCard = lib.mkOption {
type = lib.types.str;
default = "";
};
temperatureHwmon = {
isAbsolutePath = lib.mkEnableOption "absolute temperature path";
path = lib.mkOption {

View file

@ -0,0 +1,17 @@
{ lib, config, nixgl, ... }:
{
nixGL = lib.mkIf (!config.swarselsystems.isNixos) {
inherit (nixgl) packages;
defaultWrapper = lib.mkDefault "mesa";
vulkan.enable = lib.mkDefault false;
prime = lib.mkIf config.swarselsystem.isSecondaryGpu {
card = config.swarselsystem.secondaryGpuCard;
installScript = "mesa";
};
offloadWrapper = lib.mkIf config.swarselsystem.isSecondaryGpu "mesaPrime";
installScripts = [
"mesa"
"mesaPrime"
];
};
}

View file

@ -1,6 +1,6 @@
{ inputs, config, lib, ... }:
{
home-manager = lib.mkIf config.swarselsystems.withHomeManager {
extraSpecialArgs = { inherit (inputs) nix-secrets; };
extraSpecialArgs = { inherit (inputs) nix-secrets nixgl; };
};
}