{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; outputs = { self, nixpkgs, ... }: { packages.x86_64-linux = let pkgs = import nixpkgs { system = "x86_64-linux"; }; 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; }; 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} ''; }; }; }; }; }; hydraJobs = { inherit (self) packages; }; }; }