2020-11-01 12:28:27 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.caffeine;
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ maintainers.uvnikita ];
|
|
|
|
|
|
|
|
options = {
|
2023-07-01 01:30:13 +02:00
|
|
|
services.caffeine = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "Caffeine service");
|
|
|
|
};
|
2020-11-01 12:28:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.caffeine" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2020-11-01 12:28:27 +01:00
|
|
|
systemd.user.services.caffeine = {
|
|
|
|
Unit = { Description = "caffeine"; };
|
|
|
|
|
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Restart = "on-failure";
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectSystem = "full";
|
|
|
|
ProtectHome = "yes";
|
|
|
|
Type = "exec";
|
|
|
|
Slice = "session.slice";
|
|
|
|
ExecStart = "${pkgs.caffeine-ng}/bin/caffeine";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|