diff --git a/docs/manual/usage/gpu-non-nixos.md b/docs/manual/usage/gpu-non-nixos.md index 0aefa4ae3..78fd5f8de 100644 --- a/docs/manual/usage/gpu-non-nixos.md +++ b/docs/manual/usage/gpu-non-nixos.md @@ -7,7 +7,8 @@ can be integrated into Home Manager. To enable the integration, import NixGL into your home configuration, either as a channel, or as a flake input passed via `extraSpecialArgs`. Then, set the -`nixGL.packages` option to the package set provided by NixGL. +`targets.genericLinux.nixGL.packages` option to the package set provided by +NixGL. Once integration is enabled, it can be used in two ways: as Nix functions for wrapping programs installed via Home Manager, and as shell commands for running @@ -35,10 +36,11 @@ different hardware. There is also the `config.lib.nixGL.wrapOffload` alias for two-GPU systems. Another convenience is that all wrapper functions are always available. However, -when `nixGL.packages` option is unset, they are no-ops. This allows them to be -used even when the home configuration is used on NixOS machines. The exception -is the `prime-offload` script which ignores `nixGL.packages` and is installed -into the environment whenever `nixGL.prime.installScript` is set. This script, +when `targets.genericLinux.nixGL.packages` option is unset, they are no-ops. +This allows them to be used even when the home configuration is used on NixOS +machines. The exception is the `prime-offload` script which ignores +`targets.genericLinux.nixGL.packages` and is installed into the environment +whenever `targets.genericLinux.nixGL.prime.installScript` is set. This script, which can be used to start a program on a secondary GPU, does not depend on NixGL and is useful on NixOS systems as well. @@ -52,10 +54,12 @@ demonstration purposes. ```nix { config, lib, pkgs, nixgl, ... }: { - nixGL.packages = nixgl.packages; - nixGL.defaultWrapper = "mesa"; - nixGL.offloadWrapper = "nvidiaPrime"; - nixGL.installScripts = [ "mesa" "nvidiaPrime" ]; + targets.genericLinux.nixGL = { + packages = nixgl.packages; + defaultWrapper = "mesa"; + offloadWrapper = "nvidiaPrime"; + installScripts = [ "mesa" "nvidiaPrime" ]; + }; programs.mpv = { enable = true; @@ -75,7 +79,7 @@ flake. When using channels, the example would instead begin with ```nix { config, lib, pkgs, ... }: { - nixGL.packages = import { inherit pkgs; }; + targets.genericLinux.nixGL.packages = import { inherit pkgs; }; # The rest is the same as above ... ``` diff --git a/modules/modules.nix b/modules/modules.nix index bfa8c763b..d69219708 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -36,7 +36,6 @@ let ./misc/news.nix ./misc/nix-remote-build.nix ./misc/nix.nix - ./misc/nixgl.nix ./misc/numlock.nix ./misc/pam.nix ./misc/qt.nix diff --git a/modules/targets/generic-linux.nix b/modules/targets/generic-linux.nix index 9db356683..45be10acb 100644 --- a/modules/targets/generic-linux.nix +++ b/modules/targets/generic-linux.nix @@ -24,6 +24,8 @@ in "data" ] ) + (lib.mkRenamedOptionModule [ "nixGL" ] [ "targets" "genericLinux" "nixGL" ]) + ./generic-linux/nixgl.nix ]; options.targets.genericLinux = { diff --git a/modules/misc/nixgl.nix b/modules/targets/generic-linux/nixgl.nix similarity index 99% rename from modules/misc/nixgl.nix rename to modules/targets/generic-linux/nixgl.nix index 7d79b915e..5b50eb313 100644 --- a/modules/misc/nixgl.nix +++ b/modules/targets/generic-linux/nixgl.nix @@ -6,7 +6,7 @@ }: let - cfg = config.nixGL; + cfg = config.targets.genericLinux.nixGL; wrapperAttrNames = [ "mesa" @@ -21,7 +21,7 @@ in { meta.maintainers = [ lib.maintainers.smona ]; - options.nixGL = { + options.targets.genericLinux.nixGL = { packages = lib.mkOption { type = with lib.types; nullOr attrs; default = null;