notify on service failures
This commit is contained in:
parent
3622a49146
commit
8e273fedcf
6 changed files with 126 additions and 42 deletions
|
@ -1,17 +1,17 @@
|
|||
{ lib
|
||||
, fetchFromGitLab
|
||||
, flutter
|
||||
, olm
|
||||
, imagemagick
|
||||
, jack2
|
||||
, alsa-lib
|
||||
, libpulseaudio
|
||||
, fribidi
|
||||
, libgcrypt
|
||||
, libgpg-error
|
||||
, makeDesktopItem
|
||||
{
|
||||
lib,
|
||||
fetchFromGitLab,
|
||||
flutter,
|
||||
olm,
|
||||
imagemagick,
|
||||
jack2,
|
||||
alsa-lib,
|
||||
libpulseaudio,
|
||||
fribidi,
|
||||
libgcrypt,
|
||||
libgpg-error,
|
||||
makeDesktopItem,
|
||||
}:
|
||||
|
||||
flutter.mkFlutterApp rec {
|
||||
pname = "fluffychat";
|
||||
version = "1.6.1";
|
||||
|
@ -31,7 +31,7 @@ flutter.mkFlutterApp rec {
|
|||
icon = "fluffychat";
|
||||
desktopName = "Fluffychat";
|
||||
genericName = "Chat with your friends (matrix client)";
|
||||
categories = [ "Chat" "Network" "InstantMessaging" ];
|
||||
categories = ["Chat" "Network" "InstantMessaging"];
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
|
@ -89,8 +89,7 @@ flutter.mkFlutterApp rec {
|
|||
description = "Chat with your friends (matrix client)";
|
||||
homepage = "https://fluffychat.im/";
|
||||
license = licenses.agpl3Plus;
|
||||
maintainers = with maintainers; [ mkg20001 ];
|
||||
maintainers = with maintainers; [mkg20001];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
nixpkgs-fluffychat,
|
||||
...
|
||||
}: let
|
||||
pkgs-fluffychat = import nixpkgs-fluffychat { inherit (pkgs) system; };
|
||||
pkgs-fluffychat = import nixpkgs-fluffychat {inherit (pkgs) system;};
|
||||
in {
|
||||
home.packages = with pkgs; [
|
||||
(pkgs-fluffychat.callPackage ./fluffychat.nix {})
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# Largely copied from a great blog post:
|
||||
# https://sharksforarms.dev/posts/neovim-rust/
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
vim.opt = {
|
||||
completeopt = "menuone,noinsert,noselect";
|
||||
|
@ -15,15 +20,14 @@ with lib; {
|
|||
};
|
||||
|
||||
vim.keybindings.keybindings-shortened = {
|
||||
"K" = { command = "<cmd>lua vim.lsp.buf.hover()<cr>"; };
|
||||
"K" = {command = "<cmd>lua vim.lsp.buf.hover()<cr>";};
|
||||
};
|
||||
|
||||
vim.g.lightline.component_expand.lsp_status = "LspStatus";
|
||||
vim.g.lightline.active.right = mkAfter [ [ "lsp_status" ] ];
|
||||
vim.g.lightline.active.right = mkAfter [["lsp_status"]];
|
||||
|
||||
# https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/2
|
||||
output.makeWrapper =
|
||||
"--set RUST_SRC_PATH ${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
output.makeWrapper = "--set RUST_SRC_PATH ${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
|
||||
output.config_file = ''
|
||||
set shortmess+=c
|
||||
|
|
|
@ -1,29 +1,34 @@
|
|||
{ pkgs, nix-packages, config, ... }:
|
||||
let static_dir = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "akkoma-static";
|
||||
src = pkgs.emptyDirectory;
|
||||
nativeBuildInputs = with pkgs; [xorg.lndir];
|
||||
akkoma_fe = nix-packages.packages.${pkgs.system}.akkoma-fe;
|
||||
akkoma_admin_fe = nix-packages.packages.${pkgs.system}.akkoma-admin-fe;
|
||||
dontUnpack = false;
|
||||
installPhase = ''
|
||||
mkdir -p $out/frontends/pleroma-fe/stable
|
||||
lndir $akkoma_fe $out/frontends/pleroma-fe/stable
|
||||
mkdir -p $out/frontends/admin-fe/stable
|
||||
lndir $akkoma_admin_fe $out/frontends/admin-fe/stable
|
||||
'';
|
||||
};
|
||||
akkconfig = builtins.replaceStrings ["%AKKOMA_STATIC_DIR%"] ["${static_dir}"] (builtins.readFile ./akkoma.exs);
|
||||
in{
|
||||
{
|
||||
pkgs,
|
||||
nix-packages,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
static_dir = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "akkoma-static";
|
||||
src = pkgs.emptyDirectory;
|
||||
nativeBuildInputs = with pkgs; [xorg.lndir];
|
||||
akkoma_fe = nix-packages.packages.${pkgs.system}.akkoma-fe;
|
||||
akkoma_admin_fe = nix-packages.packages.${pkgs.system}.akkoma-admin-fe;
|
||||
dontUnpack = false;
|
||||
installPhase = ''
|
||||
mkdir -p $out/frontends/pleroma-fe/stable
|
||||
lndir $akkoma_fe $out/frontends/pleroma-fe/stable
|
||||
mkdir -p $out/frontends/admin-fe/stable
|
||||
lndir $akkoma_admin_fe $out/frontends/admin-fe/stable
|
||||
'';
|
||||
};
|
||||
akkconfig = builtins.replaceStrings ["%AKKOMA_STATIC_DIR%"] ["${static_dir}"] (builtins.readFile ./akkoma.exs);
|
||||
in {
|
||||
services.pleroma = {
|
||||
enable = true;
|
||||
package = nix-packages.packages.${pkgs.system}.akkoma;
|
||||
configs = [ akkconfig ];
|
||||
configs = [akkconfig];
|
||||
user = "akkoma";
|
||||
group = "akkoma";
|
||||
secretConfigFile = config.sops.secrets."services/akkoma.exs".path;
|
||||
};
|
||||
systemd.services.pleroma.path = with pkgs; [ exiftool imagemagick ffmpeg ];
|
||||
systemd.services.pleroma.path = with pkgs; [exiftool imagemagick ffmpeg];
|
||||
services.postgresql.ensureDatabases = ["akkoma"];
|
||||
services.postgresql.ensureUsers = [
|
||||
{
|
||||
|
@ -31,7 +36,7 @@ in{
|
|||
ensurePermissions = {"DATABASE akkoma" = "ALL PRIVILEGES";};
|
||||
}
|
||||
];
|
||||
sops.secrets."services/akkoma.exs" = { owner = "akkoma"; };
|
||||
sops.secrets."services/akkoma.exs" = {owner = "akkoma";};
|
||||
services.caddy.virtualHosts."akko.chir.rs" = {
|
||||
useACMEHost = "chir.rs";
|
||||
extraConfig = ''
|
||||
|
|
18
config/services/monitoring.nix
Normal file
18
config/services/monitoring.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{pkgs, ...}: {
|
||||
imports = [../../modules/systemd-email-notify.nix];
|
||||
programs.msmtp = {
|
||||
enable = true;
|
||||
accounts = {
|
||||
notif = {
|
||||
auth = true;
|
||||
tls = true;
|
||||
host = "mail.chir.rs";
|
||||
from = "notification@chir.rs";
|
||||
user = "lotte@chir.rs";
|
||||
passwordeval = "cat /run/secrets/email/lotte@chir.rs";
|
||||
};
|
||||
};
|
||||
};
|
||||
systemd.email-notify.mailFrom = "notif@chir.rs";
|
||||
systemd.email-notify.mailTo = "lotte@chir.rs";
|
||||
}
|
58
modules/systemd-email-notify.nix
Normal file
58
modules/systemd-email-notify.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Taken from https://github.com/pSub/configs/blob/master/nixops/configurations/server.pascal-wittmann.de/modules/systemd-email-notify.nix
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
sendmail =
|
||||
pkgs.writeScript "sendmail"
|
||||
''
|
||||
#!/bin/sh
|
||||
|
||||
${pkgs.system-sendmail}/bin/sendmail -t <<ERRMAIL
|
||||
To: $1
|
||||
From: ${config.systemd.email-notify.mailFrom}
|
||||
Subject: Status of service $2
|
||||
Content-Transfer-Encoding: 8bit
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
||||
$(systemctl status --full "$2")
|
||||
ERRMAIL
|
||||
'';
|
||||
in {
|
||||
options = {
|
||||
systemd.email-notify.mailTo = mkOption {
|
||||
type = types.str;
|
||||
default = null;
|
||||
description = "Email address to which the service status will be mailed.";
|
||||
};
|
||||
|
||||
systemd.email-notify.mailFrom = mkOption {
|
||||
type = types.str;
|
||||
default = null;
|
||||
description = "Email address from which the service status will be mailed.";
|
||||
};
|
||||
|
||||
systemd.services = mkOption {
|
||||
type = with types;
|
||||
attrsOf (
|
||||
submodule {
|
||||
config.onFailure = ["email@%n.service"];
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.services."email@" = {
|
||||
description = "Sends a status mail via sendmail on service failures.";
|
||||
onFailure = mkForce [];
|
||||
serviceConfig = {
|
||||
ExecStart = "${sendmail} ${config.systemd.email-notify.mailTo} %i";
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue