-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/go-neb: init #89327
nixos/go-neb: init #89327
Conversation
07275bb
to
537c8c2
Compare
f03d090
to
2195ace
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and simple module 👍
Even more bonus points if it comes with a NixOS test ✨
I have copied this module to my server and have alertmanager warnings (and a wikipedia bot) up and running with this. {
services.go-neb = {
enable = true;
baseUrl = "http://localhost";
config = {
clients = [{
UserId = "@marabot:maralorn.de";
AccessToken = config.m-0.private.matrix_marabot_token;
HomeServerUrl = "https://matrix.maralorn.de";
Sync = true;
AutoJoinRooms = true;
DisplayName = "marabot";
}];
realms = [ ];
sessions = [ ];
services = [
{
ID = "alertmanager_service";
Type = "alertmanager";
UserId = "@marabot:maralorn.de";
Config = {
webhook_url =
"http://localhost:4050/services/hooks/YWxlcnRtYW5hZ2VyX3NlcnZpY2UK";
rooms = {
"!negVsngnYOmXYCLKiO:maralorn.de" = {
text_template = ''
{{range .Alerts -}} [{{ .Status }}] {{index .Labels "alertname" }}: {{index .Annotations "description"}} {{ end -}}'';
html_template = ''
{{range .Alerts -}}
{{ $severity := index .Labels "severity" }}
{{ if eq .Status "firing" }}
{{ if eq $severity "critical"}}
<font color='red'><b>[FIRING - CRITICAL]</b></font>
{{ else if eq $severity "warning"}}
<font color='orange'><b>[FIRING - WARNING]</b></font>
{{ else }}
<b>[FIRING - {{ $severity }}]</b>
{{ end }}
{{ else }}
<font color='green'><b>[RESOLVED]</b></font>
{{ end }}
{{ index .Labels "alertname"}}:{{ index .Annotations "description"}}
<a href="{{ .GeneratorURL }}">source</a><br/>
{{end -}}
'';
msg_type = "m.text"; # Must be either `m.text` or `m.notice`
};
};
};
}
{
ID = "wikipedia_service";
Type = "wikipedia";
UserID = "@marabot:maralorn.de"; # requires a Syncing client
Config = { };
}
];
};
};
} |
Simple test added. |
d4dfe1f
to
6724f8f
Compare
In https://github.com/matrix-org/go-neb#quick-start, DATABASE_{TYPE,URL} are set, which is not replicated here. Where does this module store its state? |
@tilpner the bot has two modes. Statefully saving the config in an sqlite DB or reading the config from a config file. So the DB you are mentioning is not data state but only for config state. We opted to support only the second option, because it supports the same features and is much more nix like. |
The partial source for this statement is here: https://github.com/matrix-org/go-neb/blob/81842c69f831b7dccaa685ccacbbe218d059d76c/config.sample.yaml#L5-L9 |
I see. It surprised me that they were exclusive modes, I was hoping it would operate in a hybrid mode, as e.g. reliable RSS feed consumption requires state. Supporting only the declarative mode in this module is reasonable though. Thanks for writing it! :) |
@aanderse Are you also satisfied with the state of this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a winner in my books. Thanks for the extra work on this one. Bonus points for all! ✨
I'm not a subject matter expert so I wouldn't think to merge this... but if you're just waiting for a merge and everyone agrees I'm certainly happy to do so based on that 👍
... and just as I say that I notice the test isn't added to the list of tests. Please add and we're good. |
Simple test to start the unit with a dummy client and a dummy service and check if it can receive webhooks.
Good catch. Added here: https://github.com/NixOS/nixpkgs/pull/89327/files#diff-8e2944fa8b75f34d13428287028e1323R122 Thanks! |
@aanderse Can you maybe point us to a subject matter expert? Otherwise I'd opt for the merge. |
@GrahamcOfBorg test go-neb |
Oops! Thanks team ❤️ |
Motivation for this change
Go-neb is a matrix bot that was packaged in #87854. Now we deliver a simple module to easily set this up.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)@tilpner @maralorn