chore: add latest changes and a build

This commit is contained in:
Tommy 2024-08-11 21:02:39 +02:00
parent c669b87012
commit eb4429bc17
Signed by: tommy
SSH key fingerprint: SHA256:1LWgQT3QPHIT29plS8jjXc3S1FcE/4oGvsx3Efxs6Uc
9 changed files with 77 additions and 60 deletions

View file

@ -0,0 +1,17 @@
name: Image Build
on:
workflow_dispatch:
jobs:
prepare:
name: Prepare to Build
runs-on: ubuntu-latest-docker
container:
image: node:18
steps:
- name: Checkout
uses: actions/checkout@v4
- name: test curl
run: curl https://vg.no

View file

View file

@ -25,7 +25,7 @@ privides app to test the hooks with mocked data from `mock.json`
### Build
```sh
nix build
nix build .#container
```
### Run directly
@ -65,3 +65,7 @@ services.alertmanager-ntfy = {
envFile = "/var/src/secrets/alertmanager-ntfy/envfile";
};
```
## 🤩 Gratitude
This repo is based on the work by [pinpox/alertmanager-ntfy](https://github.com/pinpox/alertmanager-ntfy). Adaptions has been made for Kubernetes deployment.

View file

@ -2,18 +2,18 @@ with import <nixpkgs>{};
buildGoModule rec {
pname = "http2irc";
version = "0.1";
pname = "websocket2ntfy";
version = "1.0.0";
src = ./.;
src = ./src;
vendorHash = "sha256-k45e6RSIl3AQdOFQysIwJP9nlYsSFeaUznVIXfbYwLA=";
subPackages = [ "." ];
meta = with lib; {
description = "Webhook reciever to annouce in IRC channels";
homepage = "https://github.com/pinpox/http2irc";
license = licenses.gpl3;
maintainers = with maintainers; [ pinpox ];
platforms = platforms.linux;
};
meta = with pkgs.lib; {
description = "Webhook receiver to announce in ntfy-sh";
homepage = "https://code.252.no/tommy/alertmanager-ntfy";
license = pkgs.lib.licenses.gpl3;
maintainers = [ pkgs.lib.maintainers."tommy@252.no" ];
platforms = pkgs.lib.platforms.linux;
};
}

8
flake.lock generated
View file

@ -36,16 +36,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1708984720,
"narHash": "sha256-gJctErLbXx4QZBBbGp78PxtOOzsDaQ+yw1ylNQBuSUY=",
"lastModified": 1722869614,
"narHash": "sha256-7ojM1KSk3mzutD7SkrdSflHXEujPvW1u7QuqWoTLXQU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "13aff9b34cc32e59d35c62ac9356e4a41198a538",
"rev": "883180e6550c1723395a3a342f830bfc5c371f6b",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}

View file

@ -1,8 +1,8 @@
{
description = "Relay prometheus alerts to ntfy.sh";
description = "Relay Prometheus alerts to ntfy.sh";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
@ -10,52 +10,48 @@
};
};
outputs = { nixpkgs, flake-utils, self, ... }: {
nixosModules.default = ({ pkgs, ... }: {
imports = [ ./module.nix ];
# defined overlays injected by the nixflake
nixpkgs.overlays = [
(_self: _super: {
alertmanager-ntfy = self.packages.${pkgs.system}.alertmanager-ntfy;
})
];
});
} //
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
goModule = import ./default.nix { inherit pkgs; };
name = "alertmanager-ntfy";
version = "1.0.0";
in {
packages = rec {
alertmanager-ntfy = goModule;
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in rec {
packages = flake-utils.lib.flattenTree rec {
default = alertmanager-ntfy;
alertmanager-ntfy = pkgs.buildGoModule rec {
pname = "alertmanager-ntfy";
version = "1.0.0";
src = ./.;
vendorHash = "sha256-Ezt1HDxGQ7DePF90HgHKkH7v365ICFdnfcWJipLhCwQ=";
meta = with pkgs.lib; {
description = "Relay prometheus alerts to ntfy";
homepage = "https://github.com/pinpox/alertmanager-ntfy";
license = licenses.gpl3;
maintainers = with maintainers; [ pinpox ];
container = pkgs.dockerTools.buildImage {
inherit name;
tag = version;
created = "now";
copyToRoot = pkgs.buildEnv {
name = "root-env";
paths = [ alertmanager-ntfy ];
};
config.Cmd = [ "${alertmanager-ntfy}/bin/alertmanager-ntfy" ];
};
mock-hook = pkgs.writeScriptBin "mock-hook" ''
#!${pkgs.stdenv.shell}
${pkgs.curl}/bin/curl -X POST -d @mock.json http://$HTTP_ADDRESS:$HTTP_PORT
'';
};
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;
};
apps = rec {
mock-hook = flake-utils.lib.mkApp { drv = packages.mock-hook; };
alertmanager-ntfy = flake-utils.lib.mkApp { drv = packages.alertmanager-ntfy; };
defulat = alertmanager-ntfy;
};
});
nixosModules.default = ({ pkgs, ... }: {
imports = [ ./module.nix ];
nixpkgs.overlays = [
(self: super: {
alertmanager-ntfy = self.packages.${system}.alertmanager-ntfy;
})
];
});
}
);
}

View file

View file