From 651686626f7b9b3ab7b2102770c216c5fbb69f8a Mon Sep 17 00:00:00 2001 From: Mathijs Kwik Date: Sat, 24 Aug 2013 11:38:32 +0200 Subject: [PATCH] convert bbswitch job to systemd unit dramatically speeds up my boot time because it was the last service (for me) that depended on udev-settle.service udev-settle isn't needed for modern system initialization but some oldschool services (mdadm/lvm/cryptsetup) depend on it so they can just enumerate devices instead of having to react to changes dynamically. In NixOS these things are usually already taken care of during stage 1 (early ramdisk) if you use them. --- modules/services/hardware/nvidia-optimus.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/services/hardware/nvidia-optimus.nix b/modules/services/hardware/nvidia-optimus.nix index fd58b3d5ad52..79eb92c2f04d 100644 --- a/modules/services/hardware/nvidia-optimus.nix +++ b/modules/services/hardware/nvidia-optimus.nix @@ -27,13 +27,17 @@ in boot.kernelModules = [ "bbswitch" ]; boot.extraModulePackages = [ kernel.bbswitch ]; - jobs.bbswitch = { - name = "bbswitch"; + systemd.services.bbswitch = { description = "turn off nvidia card"; - startOn = "stopped udevtrigger"; - exec = "discrete_vga_poweroff"; - path = [kernel.bbswitch]; - task = true; + after = [ "sysinit.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${kernel.bbswitch}/bin/discrete_vga_poweroff"; + ExecStop = "${kernel.bbswitch}/bin/discrete_vga_poweron"; + }; + path = [ kernel.bbswitch ]; }; };