dotfiles/nix-conf/home-manager/base/graphics.nix

47 lines
1.4 KiB
Nix
Raw Permalink Normal View History

2022-12-30 08:45:15 +00:00
{ pkgs, config, lib, ... }:
let
cfg = config.base.graphics;
2023-01-13 06:56:58 +00:00
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
2022-12-30 08:45:15 +00:00
types = lib.types;
in
{
imports = [ ./shells.nix ];
options.base.graphics = {
enable = lib.mkEnableOption "graphics";
_enable = lib.mkOption {
type = types.bool;
description = "Whether the graphics is implicitly enabled (final)";
2023-01-13 07:24:32 +00:00
# internal = true;
2022-12-30 08:45:15 +00:00
default = false;
};
useNixGL = {
package = lib.mkPackageOption pkgs "nixGL package" {
default = [
"nixgl"
"auto"
"nixGLDefault"
];
};
defaultPackage = lib.mkOption {
type = types.nullOr (types.enum [ "nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee" ]);
description = "Which nixGL package to be aliased as `nixGL` on the shell";
default = null;
example = "nixGLIntel";
};
};
};
# importing shells does not mean we're enabling everything, if we do mkDefault false
# but the dilemma is, if the user import BOTH graphics.nix and shells.nix
# they will also need to do `config.base.shells.enable`
# generally, we want the behavior: import means enable
config = lib.mkIf cfgEnable {
2023-01-13 07:24:32 +00:00
base.graphics._enable = lib.mkForce true;
2022-12-30 08:45:15 +00:00
base.shells = {
shellAliases = lib.mkIf (cfg.useNixGL.defaultPackage != null) {
nixGL = cfg.useNixGL.defaultPackage;
};
};
home.packages = [ cfg.useNixGL.package ];
};
}