solid-xmpp-alarm/flake.nix

124 lines
3.6 KiB
Nix
Raw Normal View History

2023-02-04 20:15:17 +01:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }: {
packages.x86_64-linux = let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
(final: prev: {
xmppc = prev.xmppc.overrideAttrs (finalAttrs: prevAttrs: {
version = prevAttrs.version + "-password-file";
patches = [
(final.fetchpatch {
# read password from file
url = "https://codeberg.org/Anoxinon_e.V./xmppc/pulls/38.patch";
hash = "sha256-gAD0mfuvqqC7AFtMdtbW+tJiD1F9tOP6/E0eJayDXqc=";
})
];
});
})
];
2023-02-04 20:15:17 +01:00
};
in {
solid-xmpp-alarm = pkgs.rustPlatform.buildRustPackage rec {
pname = "solid-xmpp-alarm";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [
pkgs.makeWrapper
];
postInstall = ''
wrapProgram "$out/bin/solid-xmpp-alarm" \
--prefix PATH : "${pkgs.xmppc}/bin"
'';
cargoLock.lockFile = ./Cargo.lock;
};
default = self.packages.x86_64-linux.solid-xmpp-alarm;
};
apps.x86_64-linux = {
solid-xmpp-alarm = {
type = "app";
program = self.packages.x86_64-linux.solid-xmpp-alarm + "/bin/solid-xmpp-alarm";
};
default = self.apps.x86_64-linux.solid-xmpp-alarm;
};
2023-02-06 13:29:34 +01:00
nixosModules = {
solid-xmpp-alarm = { config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.solid-xmpp-alarm;
in {
options = {
services.solid-xmpp-alarm = {
enable = mkEnableOption "Prometheus Alertmanager webhook receiver for XMPP clients";
jid = mkOption {
type = types.str;
description = ''
XMPP account name of the sender.
'';
};
passwordFile = mkOption {
type = types.path;
description = ''
Path to file containing the password to log into the senders account.
'';
};
receiver = mkOption {
type = types.str;
description = ''
XMPP account name of the receiver.
'';
};
package = mkOption {
type = types.package;
default = self.packages.${config.nixpkgs.system}.solid-xmpp-alarm;
description = ''
Specify a custom solid-xmpp-alarm package. By default use the one shipped with this flake.
'';
};
};
};
config = mkIf cfg.enable {
users.users."solid-xmpp-alarm" = {
isSystemUser = true;
group = "solid-xmpp-alarm";
};
users.groups."solid-xmpp-alarm" = {};
systemd.services."solid-xmpp-alarm" = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Restart = "always";
PrivateTmp = true;
WorkingDirectory = "/tmp";
RuntimeDirectory = "solid-xmpp-alarm";
User = "solid-xmpp-alarm";
Group = "solid-xmpp-alarm";
ExecStart = ''
${cfg.package}/bin/solid-xmpp-alarm --jid ${cfg.jid} --password-file ${cfg.passwordFile} --receiver ${cfg.receiver}
'';
};
};
};
};
};
2023-02-04 20:15:17 +01:00
hydraJobs = {
inherit (self)
packages;
};
};
}