mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-19 00:20:32 +03:00

After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
--argstr baseRev 0128fbb0a5
result/bin/apply-formatting $NIXPKGS_PATH
113 lines
2.6 KiB
Nix
113 lines
2.6 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
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 = lib.mkOption {
|
|
default = false;
|
|
type = lib.types.bool;
|
|
description = ''
|
|
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 = lib.mkOption {
|
|
default = "wheel";
|
|
example = "video";
|
|
type = lib.types.str;
|
|
description = "Group for bumblebee socket";
|
|
};
|
|
|
|
connectDisplay = lib.mkOption {
|
|
default = false;
|
|
type = lib.types.bool;
|
|
description = ''
|
|
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 = lib.mkOption {
|
|
default = "nvidia";
|
|
type = lib.types.enum [
|
|
"nvidia"
|
|
"nouveau"
|
|
];
|
|
description = ''
|
|
Set driver used by bumblebeed. Supported are nouveau and nvidia.
|
|
'';
|
|
};
|
|
|
|
pmMethod = lib.mkOption {
|
|
default = "auto";
|
|
type = lib.types.enum [
|
|
"auto"
|
|
"bbswitch"
|
|
"switcheroo"
|
|
"none"
|
|
];
|
|
description = ''
|
|
Set preferred power management method for unused card.
|
|
'';
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
boot.blacklistedKernelModules = [
|
|
"nvidia-drm"
|
|
"nvidia"
|
|
"nouveau"
|
|
];
|
|
boot.kernelModules = lib.optional useBbswitch "bbswitch";
|
|
boot.extraModulePackages =
|
|
lib.optional useBbswitch kernel.bbswitch
|
|
++ lib.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}";
|
|
};
|
|
};
|
|
};
|
|
}
|