2023-06-18 00:46:31 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2022-12-30 08:45:15 +00:00
|
|
|
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;
|
2023-06-18 00:46:31 +00:00
|
|
|
in {
|
|
|
|
imports = [./shells.nix];
|
2022-12-30 08:45:15 +00:00
|
|
|
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 {
|
2023-06-18 00:46:31 +00:00
|
|
|
type = types.nullOr (types.enum ["nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee"]);
|
2022-12-30 08:45:15 +00:00
|
|
|
description = "Which nixGL package to be aliased as `nixGL` on the shell";
|
|
|
|
default = null;
|
|
|
|
example = "nixGLIntel";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-06-16 23:12:54 +00:00
|
|
|
# NOTE: importing shells does not mean we're enabling everything, if we do mkDefault false
|
2022-12-30 08:45:15 +00:00
|
|
|
# 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;
|
|
|
|
};
|
|
|
|
};
|
2023-06-18 00:46:31 +00:00
|
|
|
home.packages = [cfg.useNixGL.package];
|
2022-12-30 08:45:15 +00:00
|
|
|
};
|
|
|
|
}
|