blob: 0b7eb39de9c8975d7167b8a8398c676c81d145a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.castsponsorskip;
in
{
options = {
services.castsponsorskip = {
enable = lib.mkEnableOption "castsponsorskip";
package = lib.mkPackageOption pkgs "castsponsorskip" { };
config = lib.mkOption {
type = (pkgs.formats.yaml { }).type;
default = { };
example = {
CSS_SKIP_SPONSORS = false;
};
description = "Configuration for the service. List of options all options <https://github.com/gabe565/CastSponsorSkip/blob/main/docs/envs.md>.";
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.castsponsorskip =
let
# Needed, even if empty, to avoid searching for a file in
# the user home directory, which doesn't exist for
# dynamic users
config = (pkgs.formats.yaml cfg.config).generate "config.yaml" { };
in
{
description = "Skip YouTube ads and sponsorships on all local Google Cast devices";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
Restart = "always";
ExecStart = "${lib.getExe cfg.package} --config=${config}";
TimeoutStopSec = "20s";
};
};
};
meta = {
maintainers = with lib.maintainers; [ wariuccio ];
};
}
|