Skip to content

Commit

Permalink
nixos/opengl: remove with lib over entire file
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Jun 5, 2024
1 parent a720a0f commit 0898fee
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions nixos/modules/hardware/opengl.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.hardware.opengl;
Expand All @@ -25,14 +23,14 @@ in
{

imports = [
(mkRenamedOptionModule [ "services" "xserver" "vaapiDrivers" ] [ "hardware" "opengl" "extraPackages" ])
(mkRemovedOptionModule [ "hardware" "opengl" "s3tcSupport" ] "S3TC support is now always enabled in Mesa.")
(lib.mkRenamedOptionModule [ "services" "xserver" "vaapiDrivers" ] [ "hardware" "opengl" "extraPackages" ])
(lib.mkRemovedOptionModule [ "hardware" "opengl" "s3tcSupport" ] "S3TC support is now always enabled in Mesa.")
];

options = {

hardware.opengl = {
enable = mkOption {
enable = lib.mkOption {
description = ''
Whether to enable OpenGL drivers. This is needed to enable
OpenGL support in X11 systems, as well as for Wayland compositors
Expand All @@ -42,21 +40,21 @@ in
compositor of choice. See services.xserver.enable and
programs.sway.enable.
'';
type = types.bool;
type = lib.types.bool;
default = false;
};

driSupport = mkOption {
type = types.bool;
driSupport = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable accelerated OpenGL rendering through the
Direct Rendering Interface (DRI).
'';
};

driSupport32Bit = mkOption {
type = types.bool;
driSupport32Bit = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
On 64-bit systems, whether to support Direct Rendering for
Expand All @@ -66,16 +64,16 @@ in
'';
};

package = mkOption {
type = types.package;
package = lib.mkOption {
type = lib.types.package;
internal = true;
description = ''
The package that provides the OpenGL implementation.
'';
};

package32 = mkOption {
type = types.package;
package32 = lib.mkOption {
type = lib.types.package;
internal = true;
description = ''
The package that provides the 32-bit OpenGL implementation on
Expand All @@ -84,10 +82,10 @@ in
'';
};

extraPackages = mkOption {
type = types.listOf types.package;
extraPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
example = literalExpression "with pkgs; [ intel-media-driver intel-ocl intel-vaapi-driver ]";
example = lib.literalExpression "with pkgs; [ intel-media-driver intel-ocl intel-vaapi-driver ]";
description = ''
Additional packages to add to OpenGL drivers.
This can be used to add OpenCL drivers, VA-API/VDPAU drivers etc.
Expand All @@ -98,10 +96,10 @@ in
'';
};

extraPackages32 = mkOption {
type = types.listOf types.package;
extraPackages32 =lib. mkOption {
type = lib.types.listOf lib.types.package;
default = [];
example = literalExpression "with pkgs.pkgsi686Linux; [ intel-media-driver intel-vaapi-driver ]";
example = lib.literalExpression "with pkgs.pkgsi686Linux; [ intel-media-driver intel-vaapi-driver ]";
description = ''
Additional packages to add to 32-bit OpenGL drivers on 64-bit systems.
Used when {option}`driSupport32Bit` is set. This can be used to add OpenCL drivers, VA-API/VDPAU drivers etc.
Expand All @@ -112,8 +110,8 @@ in
'';
};

setLdLibraryPath = mkOption {
type = types.bool;
setLdLibraryPath = lib.mkOption {
type = lib.types.bool;
internal = true;
default = false;
description = ''
Expand All @@ -128,7 +126,7 @@ in

};

config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
assertions = [
{ assertion = cfg.driSupport32Bit -> pkgs.stdenv.isx86_64;
message = "Option driSupport32Bit only makes sense on a 64-bit system.";
Expand All @@ -150,12 +148,12 @@ in
)
];

environment.sessionVariables.LD_LIBRARY_PATH = mkIf cfg.setLdLibraryPath
([ "/run/opengl-driver/lib" ] ++ optional cfg.driSupport32Bit "/run/opengl-driver-32/lib");
environment.sessionVariables.LD_LIBRARY_PATH = lib.mkIf cfg.setLdLibraryPath
([ "/run/opengl-driver/lib" ] ++ lib.optional cfg.driSupport32Bit "/run/opengl-driver-32/lib");

hardware.opengl.package = mkDefault pkgs.mesa.drivers;
hardware.opengl.package32 = mkDefault pkgs.pkgsi686Linux.mesa.drivers;
hardware.opengl.package = lib.mkDefault pkgs.mesa.drivers;
hardware.opengl.package32 = lib.mkDefault pkgs.pkgsi686Linux.mesa.drivers;

boot.extraModulePackages = optional (elem "virtualbox" videoDrivers) kernelPackages.virtualboxGuestAdditions;
boot.extraModulePackages = lib.optional (lib.elem "virtualbox" videoDrivers) kernelPackages.virtualboxGuestAdditions;
};
}

0 comments on commit 0898fee

Please sign in to comment.