Mon Jun 10 04:28:16 PM CEST 2024
This commit is contained in:
parent
c7da813de2
commit
2a90b44b84
|
@ -2,17 +2,9 @@
|
|||
|
||||
{
|
||||
imports = [
|
||||
(import ./common.nix { inherit inputs config pkgs; })
|
||||
(import ./hyprland { inherit inputs pkgs; })
|
||||
(import ./waybar { inherit inputs pkgs; })
|
||||
./rofi
|
||||
./alacritty
|
||||
./kitty
|
||||
./firefox
|
||||
./ssh
|
||||
./mpv
|
||||
(import ./utils/desktop.nix { inherit inputs config pkgs; })
|
||||
];
|
||||
home.packages = with pkgs; [ telegram-desktop webcord devenv iwgtk element-desktop ];
|
||||
|
||||
programs.ssh.matchBlocks."*".identityFile = "/home/user/.secrets/SSH/Aloria/id_ed25519";
|
||||
|
||||
services.hyprpaper = {
|
||||
|
|
|
@ -2,17 +2,8 @@
|
|||
|
||||
{
|
||||
imports = [
|
||||
(import ./common.nix { inherit inputs config pkgs; })
|
||||
(import ./hyprland { inherit inputs pkgs; })
|
||||
(import ./waybar { inherit inputs pkgs; })
|
||||
./rofi
|
||||
./alacritty
|
||||
./kitty
|
||||
./firefox
|
||||
./ssh
|
||||
./mpv
|
||||
(import ./utils/desktop.nix { inherit inputs config pkgs; })
|
||||
];
|
||||
home.packages = with pkgs; [ telegram-desktop webcord devenv loupe evince ];
|
||||
programs.ssh.matchBlocks."*".identityFile = "/home/server/.secrets/SSH/Kell/id_ed25519";
|
||||
|
||||
services.hyprpaper = {
|
||||
|
|
|
@ -1,51 +1,5 @@
|
|||
{ inputs, config, pkgs, ... }:
|
||||
let
|
||||
notify_script = (pkgs.writers.writePython3Bin "telegram-notify.py" {
|
||||
libraries = [ pkgs.python3Packages.python-telegram-bot ];
|
||||
} ''
|
||||
import telegram
|
||||
import asyncio
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
async def run():
|
||||
text = subprocess.check_output(
|
||||
["journalctl", "--user", "-u", sys.argv[1], "-b"]
|
||||
).decode("utf-8")
|
||||
|
||||
with open("/home/server/mail.log", "a") as f:
|
||||
f.write("===========================================")
|
||||
f.write(text)
|
||||
|
||||
bot = telegram.Bot(token="381718873:AAElFmI2BDjumCehhWicuksE0vutrPSkoGA")
|
||||
chat_id = 125754925
|
||||
await bot.send_message(
|
||||
chat_id, "Mallorea encountered an error in the service: " + sys.argv[1]
|
||||
)
|
||||
|
||||
await bot.send_message(chat_id, text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(asyncio.wait([loop.create_task(run())]))
|
||||
loop.close()
|
||||
'');
|
||||
mkTimer = name: cfg: {
|
||||
Install.WantedBy = [ "timers.target" ];
|
||||
Timer = {
|
||||
Persistent = true;
|
||||
OnCalendar = cfg.when;
|
||||
Unit = "${name}.service";
|
||||
};
|
||||
};
|
||||
mkService = name: cfg: {
|
||||
Unit.Description = name;
|
||||
Unit.OnFailure = "status_notify@%n.service";
|
||||
Install = { WantedBy = [ "default.target" ]; };
|
||||
Service = { ExecStart = cfg.script; };
|
||||
};
|
||||
scripts = {
|
||||
disk_check = {
|
||||
when = "*-*-* *:00:00";
|
||||
|
@ -120,8 +74,12 @@ in {
|
|||
};
|
||||
|
||||
xdg.enable = true;
|
||||
# home.profileDirectory = "${config.xdg.stateHome}/nix/profile";
|
||||
imports = [ (import ./common.nix { inherit inputs config pkgs; }) ./ssh ];
|
||||
|
||||
imports = [
|
||||
(import ./utils/common.nix { inherit inputs config pkgs; })
|
||||
(import ./utils/services.nix { inherit pkgs; scripts=scripts; })
|
||||
./ssh
|
||||
];
|
||||
programs.ssh.matchBlocks."*".identityFile = "/home/server/.secrets/SSH/Mallorea/id_ed25519";
|
||||
|
||||
home.sessionVariables = {
|
||||
|
@ -129,19 +87,4 @@ in {
|
|||
LANG = "en_US.UTF-8";
|
||||
XDG_RUNTIME_DIR = "/run/user/$(id -u)";
|
||||
};
|
||||
|
||||
systemd.user.services = pkgs.lib.mapAttrs mkService scripts
|
||||
// (pkgs.lib.mapAttrs mkService {
|
||||
"status_notify@" = {
|
||||
script = "${notify_script}/bin/telegram-notify.py %i";
|
||||
};
|
||||
});
|
||||
systemd.user.timers = pkgs.lib.mapAttrs mkTimer scripts;
|
||||
|
||||
# Don't forget to enable these timers! Or reboot, after which it should also be activated automatically
|
||||
# systemctl --user enable --now backup.timer
|
||||
# systemctl --user enable --now sync_vault.timer
|
||||
# systemctl --user enable --now mbsync.timer
|
||||
# systemctl --user enable --now vdirsyncer.timer
|
||||
# systemctl --user enable --now disk_check.timer
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ inputs, config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./zsh ./git ./nvim ./email ./lf ./tmux ];
|
||||
imports = [ ../zsh ../git ../nvim ../email ../lf ../tmux ];
|
||||
|
||||
home.stateVersion = "24.11";
|
||||
targets.genericLinux.enable = true;
|
|
@ -0,0 +1,23 @@
|
|||
{ inputs, config, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import ./common.nix { inherit inputs config pkgs; })
|
||||
(import ../hyprland { inherit inputs pkgs; })
|
||||
(import ../waybar { inherit inputs pkgs; })
|
||||
../rofi
|
||||
../alacritty
|
||||
../kitty
|
||||
../firefox
|
||||
../ssh
|
||||
../mpv
|
||||
];
|
||||
home.packages = with pkgs; [
|
||||
telegram-desktop
|
||||
webcord
|
||||
devenv
|
||||
iwgtk
|
||||
element-desktop
|
||||
evince
|
||||
loupe
|
||||
];
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
{ pkgs, scripts }:
|
||||
let
|
||||
notify_script = (pkgs.writers.writePython3Bin "telegram-notify.py" {
|
||||
libraries = [ pkgs.python3Packages.python-telegram-bot ];
|
||||
} ''
|
||||
import telegram
|
||||
import asyncio
|
||||
import sys
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
|
||||
async def run():
|
||||
text = subprocess.check_output(
|
||||
["journalctl", "--user", "-u", sys.argv[1], "-b"]
|
||||
).decode("utf-8")
|
||||
|
||||
with open("/home/server/mail.log", "a") as f:
|
||||
f.write("===========================================")
|
||||
f.write(text)
|
||||
|
||||
bot = telegram.Bot(token="381718873:AAElFmI2BDjumCehhWicuksE0vutrPSkoGA")
|
||||
chat_id = 125754925
|
||||
hostname = socket.gethostname()
|
||||
await bot.send_message(chat_id, f"{hostname} encountered an error in the service: {sys.argv[1]}")
|
||||
|
||||
await bot.send_message(chat_id, text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(asyncio.wait([loop.create_task(run())]))
|
||||
loop.close()
|
||||
'');
|
||||
|
||||
mkTimer = name: cfg: {
|
||||
Install.WantedBy = [ "timers.target" ];
|
||||
Timer = {
|
||||
Persistent = true;
|
||||
OnCalendar = cfg.when;
|
||||
Unit = "${name}.service";
|
||||
};
|
||||
};
|
||||
mkService = name: cfg: {
|
||||
Unit.Description = name;
|
||||
Unit.OnFailure = "status_notify@%n.service";
|
||||
Install = { WantedBy = [ "default.target" ]; };
|
||||
Service = { ExecStart = cfg.script; };
|
||||
};
|
||||
in
|
||||
{
|
||||
systemd.user.services = pkgs.lib.mapAttrs mkService scripts
|
||||
// (pkgs.lib.mapAttrs mkService {
|
||||
"status_notify@" = {
|
||||
script = "${notify_script}/bin/telegram-notify.py %i";
|
||||
};
|
||||
});
|
||||
systemd.user.timers = pkgs.lib.mapAttrs mkTimer scripts;
|
||||
# Don't forget to enable these timers! Or reboot, after which it should also be activated automatically
|
||||
# systemctl --user enable --now <script>.timer
|
||||
}
|
Loading…
Reference in New Issue