-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch-presence.nix
66 lines (66 loc) · 1.87 KB
/
switch-presence.nix
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.switch-presence;
presence-client = pkgs.stdenvNoCC.mkDerivation {
pname = "presence-client";
version = "unstable-2023-12-19";
src = pkgs.fetchFromGitHub {
owner = "lenooby09";
repo = "presenceclient";
rev = "890c510f27add83eaa0217444d7385cceb45ee08";
hash = "sha256-34rCyEJ9jiAYxrOMo5uzuX1mi7Kw5vcZZc4p0NuIkeE=";
};
# Runtime dependencies
propagatedBuildInputs = [
(pkgs.python3.withPackages (pythonPackages:
with pythonPackages; [
requests
pypresence
python-dotenv
]))
];
installPhase = ''
install -Dm755 PresenceClient/PresenceClient-Py/presence-client.py $out/bin/presence-client
sed -i '1 i #!/usr/bin/env python3' $out/bin/presence-client
'';
};
in {
options = {
services.switch-presence = {
enable = mkOption {
type = types.bool;
default = false;
};
args = mkOption {
type = types.str;
default = "--ignore-tinfoil --low-latancy";
};
environmentFile = mkOption {
type = types.nullOr types.path;
example = ''
You must specify an environment file containing both
$IP: The IP address of your device.
$APPLICATION_ID: The Client ID of your Discord Rich Presence application.
'';
};
};
};
config = mkIf cfg.enable {
systemd.user.services.switch-presence = {
enable = true;
description = "Nintendo switch discord rich presence client";
wantedBy = ["default.target"];
serviceConfig = {
EnvironmentFile = config.services.switch-presence.environmentFile;
ExecStart = "${presence-client}/bin/presence-client ${config.services.switch-presence.args}";
Restart = "on-failure";
RestartSec = "60s";
};
};
};
}