mirror of
https://github.com/nix-community/home-manager
synced 2024-11-01 00:39:45 +01:00
nixgl: add support for channel-based configuration
This commit is contained in:
parent
7a5879707b
commit
8bd6e0a1a8
2 changed files with 34 additions and 4 deletions
|
@ -50,9 +50,9 @@ Xonotic to run on the dGPU, but uses the wrapper function directly for
|
|||
demonstration purposes.
|
||||
|
||||
```nix
|
||||
{ config, lib, pkgs, nixGL, ... }:
|
||||
{ config, lib, pkgs, nixgl, ... }:
|
||||
{
|
||||
nixGL.packages = nixGL.packages;
|
||||
nixGL.packages = nixgl.packages;
|
||||
nixGL.defaultWrapper = "mesa";
|
||||
nixGL.offloadWrapper = "nvidiaPrime";
|
||||
nixGL.installScripts = [ "mesa" "nvidiaPrime" ];
|
||||
|
@ -68,3 +68,14 @@ demonstration purposes.
|
|||
];
|
||||
}
|
||||
```
|
||||
|
||||
The above example assumes a flake-based setup where `nixgl` was passed from the
|
||||
flake. When using channels, the example would instead begin with
|
||||
|
||||
```nix
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
nixGL.packages = import <nixgl> { inherit pkgs; };
|
||||
# The rest is the same as above
|
||||
...
|
||||
```
|
||||
|
|
|
@ -138,11 +138,30 @@ in {
|
|||
};
|
||||
|
||||
config = let
|
||||
findWrapperPackage = packageAttr:
|
||||
# NixGL has wrapper packages in different places depending on how you
|
||||
# access it. We want HM configuration to be the same, regardless of how
|
||||
# NixGL is imported.
|
||||
#
|
||||
# First, let's see if we have a flake.
|
||||
if builtins.hasAttr pkgs.system cfg.packages then
|
||||
cfg.packages.${pkgs.system}.${packageAttr}
|
||||
else
|
||||
# Next, let's see if we have a channel.
|
||||
if builtins.hasAttr packageAttr cfg.packages then
|
||||
cfg.packages.${packageAttr}
|
||||
else
|
||||
# Lastly, with channels, some wrappers are grouped under "auto".
|
||||
if builtins.hasAttr "auto" cfg.packages then
|
||||
cfg.packages.auto.${packageAttr}
|
||||
else
|
||||
throw "Incompatible NixGL package layout";
|
||||
|
||||
getWrapperExe = vendor:
|
||||
let
|
||||
glPackage = cfg.packages.${pkgs.system}."nixGL${vendor}";
|
||||
glPackage = findWrapperPackage "nixGL${vendor}";
|
||||
glExe = lib.getExe glPackage;
|
||||
vulkanPackage = cfg.packages.${pkgs.system}."nixVulkan${vendor}";
|
||||
vulkanPackage = findWrapperPackage "nixVulkan${vendor}";
|
||||
vulkanExe = if cfg.vulkan.enable then lib.getExe vulkanPackage else "";
|
||||
in "${glExe} ${vulkanExe}";
|
||||
|
||||
|
|
Loading…
Reference in a new issue