-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.nix
More file actions
104 lines (90 loc) · 2.45 KB
/
module.nix
File metadata and controls
104 lines (90 loc) · 2.45 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
flake: {
config,
lib,
pkgs,
...
}: let
cfg = config.services.auto_profile_tg;
pkg = flake.packages.${pkgs.stdenv.hostPlatform.system}.default;
homeDir = config.users.users.bahrom04.home;
in {
options = {
services.auto_profile_tg = {
enable = lib.mkEnableOption "auto_profile_tg";
# Telegram API credentials from my.telegram.org
api_id = lib.mkOption {
type = lib.types.str;
default = 0;
example = 12345678;
};
api_hash = lib.mkOption {
type = lib.types.str;
default = "";
};
phone_number = lib.mkOption {
type = lib.types.str;
example = "+998123456789";
};
first_name = lib.mkOption {
type = lib.types.str;
example = "John";
};
lat = lib.mkOption {
type = lib.types.str;
example = "41.2995";
};
lon = lib.mkOption {
type = lib.types.str;
example = "69.2401";
};
timezone = lib.mkOption {
type = lib.types.str;
example = "Asia/Tashkent";
};
city = lib.mkOption {
type = lib.types.str;
example = "Tashkent";
};
weather_api_key = lib.mkOption {
type = lib.types.str;
};
};
};
config = lib.mkIf cfg.enable {
# systemd.services.auto-profile-tg = {
# description = "run the bot on systemd";
# environment = {
# PYTHONUNBUFFERED = "1";
# };
# after = [ "network.target" ];
# wantedBy = [ "network.target" ];
# ExecStart = "${auto-profile-tg}/bin/main.py";
# Restart = "always";
# RestartSec = "5";
# };
# I use mac btw
launchd.user.agents = {
auto_profile_tg = {
serviceConfig = {
# Program = "${pkg}/bin/runner";
ProgramArguments = [
"${pkg}/bin/runner"
"--api_id=${cfg.api_id}"
"--api_hash=${cfg.api_hash}"
"--phone_number=${cfg.phone_number}"
"--first_name=${cfg.first_name}"
"--lat=${cfg.lat}"
"--lon=${cfg.lon}"
"--timezone=${cfg.timezone}"
"--city=${cfg.city}"
"--weather_api_key=${cfg.weather_api_key}"
];
StandardOutPath = "/${homeDir}/Library/Logs/auto_profile_tg.log";
StandardErrorPath = "/${homeDir}/Library/Logs/auto_profile_tg_error.log";
KeepAlive = true;
RunAtLoad = true;
};
};
};
};
}