{ description = "Relay Prometheus alerts to ntfy.sh"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; flake-utils.url = "github:numtide/flake-utils"; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; }; outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; goModule = import ./default.nix { inherit pkgs; }; name = "alertmanager-ntfy"; registry = "code.252.no/tommy/alertmanager-ntfy"; version = "1.0.2"; in { packages = rec { alertmanager-ntfy = goModule; container = pkgs.dockerTools.buildImage { inherit name; tag = version; created = "now"; copyToRoot = pkgs.buildEnv { name = "root-env"; paths = [ alertmanager-ntfy pkgs.cacert ]; }; config.Cmd = [ "${alertmanager-ntfy}/bin/alertmanager-ntfy" ]; }; push-container = pkgs.writeShellScriptBin "push-container" '' #!/usr/bin/env bash set -e # Build the image and load it to Docker echo "Loading Docker image..." ${pkgs.docker}/bin/docker load < ${self.packages.${system}.container} # Tag the image echo "Tagging Docker image..." ${pkgs.docker}/bin/docker tag ${name}:${version} ${registry}:${version} # Push the image to the Docker registry echo "Pushing Docker image to ${registry}:${version}..." ${pkgs.docker}/bin/docker push ${registry}:${version} ''; mock-hook = pkgs.writeScriptBin "mock-hook" '' #!${pkgs.stdenv.shell} ${pkgs.curl}/bin/curl -X POST -d @mock.json http://$HTTP_ADDRESS:$HTTP_PORT ''; }; apps = rec { mock-hook = flake-utils.lib.mkApp { drv = self.packages.${system}.mock-hook; }; alertmanager-ntfy = flake-utils.lib.mkApp { drv = self.packages.${system}.alertmanager-ntfy; }; default = alertmanager-ntfy; }; nixosModules.default = ({ pkgs, ... }: { imports = [ ./module.nix ]; nixpkgs.overlays = [ (self: super: { alertmanager-ntfy = self.packages.${system}.alertmanager-ntfy; }) ]; }); } ); }