diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-05-31 09:59:33 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-05-31 09:59:57 +0000 |
commit | 9ff36293d1e428cd7bf03e8d4b03611b6d361c28 (patch) | |
tree | 1ab51a42b868c55b83f6ccdb80371b9888739dd9 /nixos/modules/hardware/video/bumblebee.nix | |
parent | 1c4fcd0d4b0541e674ee56ace1053e23e562cc80 (diff) | |
parent | ddc3c396a51918043bb0faa6f676abd9562be62c (diff) | |
download | nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.gz nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.bz2 nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.lz nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.xz nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.tar.zst nixpkgs-9ff36293d1e428cd7bf03e8d4b03611b6d361c28.zip |
Last good Nixpkgs for Weston+nouveau? archive
I came this commit hash to terwiz[m] on IRC, who is trying to figure out what the last version of Spectrum that worked on their NUC with Nvidia graphics is.
Diffstat (limited to 'nixos/modules/hardware/video/bumblebee.nix')
-rw-r--r-- | nixos/modules/hardware/video/bumblebee.nix | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/nixos/modules/hardware/video/bumblebee.nix b/nixos/modules/hardware/video/bumblebee.nix new file mode 100644 index 00000000000..b6af4f80445 --- /dev/null +++ b/nixos/modules/hardware/video/bumblebee.nix @@ -0,0 +1,93 @@ +{ 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 = '' + 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 = "Group for bumblebee socket"; + }; + + connectDisplay = mkOption { + default = false; + type = 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 = mkOption { + default = "nvidia"; + type = types.enum [ "nvidia" "nouveau" ]; + description = '' + Set driver used by bumblebeed. Supported are nouveau and nvidia. + ''; + }; + + pmMethod = mkOption { + default = "auto"; + type = types.enum [ "auto" "bbswitch" "switcheroo" "none" ]; + description = '' + 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}"; + }; + }; + }; +} |