the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
94 lines
2.5 KiB
Nix
94 lines
2.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.hardware.bumblebee;
|
|
|
|
kernel = config.boot.kernelPackages;
|
|
|
|
useNvidia = cfg.driver == "nvidia";
|
|
|
|
bumblebee = pkgs.bumblebee.override {
|
|
inherit useNvidia;
|
|
useDisplayDevice = cfg.connectDisplay;
|
|
};
|
|
|
|
useBbswitch = cfg.pmMethod == "bbswitch" || cfg.pmMethod == "auto" && useNvidia;
|
|
|
|
primus = pkgs.primus.override {
|
|
inherit useNvidia;
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
hardware.bumblebee = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Enable the bumblebee daemon to manage Optimus hybrid video cards.
|
|
This should power off secondary GPU until its use is requested
|
|
by running an application with optirun.
|
|
'';
|
|
};
|
|
|
|
group = mkOption {
|
|
default = "wheel";
|
|
example = "video";
|
|
type = types.str;
|
|
description = lib.mdDoc "Group for bumblebee socket";
|
|
};
|
|
|
|
connectDisplay = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Set to true if you intend to connect your discrete card to a
|
|
monitor. This option will set up your Nvidia card for EDID
|
|
discovery and to turn on the monitor signal.
|
|
|
|
Only nvidia driver is supported so far.
|
|
'';
|
|
};
|
|
|
|
driver = mkOption {
|
|
default = "nvidia";
|
|
type = types.enum [ "nvidia" "nouveau" ];
|
|
description = lib.mdDoc ''
|
|
Set driver used by bumblebeed. Supported are nouveau and nvidia.
|
|
'';
|
|
};
|
|
|
|
pmMethod = mkOption {
|
|
default = "auto";
|
|
type = types.enum [ "auto" "bbswitch" "switcheroo" "none" ];
|
|
description = lib.mdDoc ''
|
|
Set preferred power management method for unused card.
|
|
'';
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
boot.blacklistedKernelModules = [ "nvidia-drm" "nvidia" "nouveau" ];
|
|
boot.kernelModules = optional useBbswitch "bbswitch";
|
|
boot.extraModulePackages = optional useBbswitch kernel.bbswitch ++ optional useNvidia kernel.nvidia_x11.bin;
|
|
|
|
environment.systemPackages = [ bumblebee primus ];
|
|
|
|
systemd.services.bumblebeed = {
|
|
description = "Bumblebee Hybrid Graphics Switcher";
|
|
wantedBy = [ "multi-user.target" ];
|
|
before = [ "display-manager.service" ];
|
|
serviceConfig = {
|
|
ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver} --pm-method ${cfg.pmMethod}";
|
|
};
|
|
};
|
|
};
|
|
}
|