Skip to content

Instantly share code, notes, and snippets.

@sondr3
Created April 15, 2018 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sondr3/351dc22751aaed7d8a76d62702846003 to your computer and use it in GitHub Desktop.
Save sondr3/351dc22751aaed7d8a76d62702846003 to your computer and use it in GitHub Desktop.
{config, options, lib, pkgs, ...}:
with lib;
let
cfg = config.services.vgaswitcheroo;
in {
options.services.vgaswitcheroo = with types; {
enable = mkOption {
type = bool;
default = false;
description = ''
Enable vgaswitcheroo.
'';
};
};
config = mkIf cfg.enable {
systemd.services.vgaswitcheroo = {
wantedBy = [ "multi-user.target" ];
description = "Deactivate the discrete GPU on boot";
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = "";
ExecStop = "";
};
};
};
}
@infinisil
Copy link

# ...
with lib;

let

  vgaswitcheroo = pkgs.stdenv.mkDerivation {
    name = "vgaswitcheroo";
    src = pkgs.fetchFromGitHub {
      owner = "...";
      repo = "...";
      rev = "...";
      sha256 = "...";
    };
    
    buildInputs = with pkgs; [
      # ...
    ];
  };
  cfg = config.services.vgaswitcheroo;
in {
# ...
    ExecStart = "${vgaswitcheroo}/bin/foobar --some --arguments";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment