mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
nixos/gatus: init module (#294469)
This commit is contained in:
commit
075be3e70b
|
@ -16660,6 +16660,12 @@
|
|||
githubId = 14542417;
|
||||
name = "Sergey Ichtchenko";
|
||||
};
|
||||
pizzapim = {
|
||||
email = "pim@kunis.nl";
|
||||
github = "pizzapim";
|
||||
githubId = 23135512;
|
||||
name = "Pim Kunis";
|
||||
};
|
||||
pjbarnoy = {
|
||||
email = "pjbarnoy@gmail.com";
|
||||
github = "waaamb";
|
||||
|
|
|
@ -120,6 +120,8 @@
|
|||
|
||||
- [Localsend](https://localsend.org/), an open source cross-platform alternative to AirDrop. Available as [programs.localsend](#opt-programs.localsend.enable).
|
||||
|
||||
- [Gatus](https://github.com/TwiN/gatus), an automated developer-oriented status page. Available as [services.gatus](#opt-services.gatus.enable).
|
||||
|
||||
- [cryptpad](https://cryptpad.org/), a privacy-oriented collaborative platform (docs/drive/etc), has been added back. Available as [services.cryptpad](#opt-services.cryptpad.enable).
|
||||
|
||||
- [realm](https://github.com/zhboner/realm), a simple, high performance relay server written in rust. Available as [services.realm.enable](#opt-services.realm.enable).
|
||||
|
|
|
@ -883,6 +883,7 @@
|
|||
./services/monitoring/datadog-agent.nix
|
||||
./services/monitoring/do-agent.nix
|
||||
./services/monitoring/fusion-inventory.nix
|
||||
./services/monitoring/gatus.nix
|
||||
./services/monitoring/goss.nix
|
||||
./services/monitoring/grafana-agent.nix
|
||||
./services/monitoring/grafana-image-renderer.nix
|
||||
|
|
132
nixos/modules/services/monitoring/gatus.nix
Normal file
132
nixos/modules/services/monitoring/gatus.nix
Normal file
|
@ -0,0 +1,132 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.gatus;
|
||||
|
||||
settingsFormat = pkgs.formats.yaml { };
|
||||
|
||||
inherit (lib)
|
||||
getExe
|
||||
literalExpression
|
||||
maintainers
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
mkPackageOption
|
||||
;
|
||||
|
||||
inherit (lib.types)
|
||||
bool
|
||||
int
|
||||
nullOr
|
||||
path
|
||||
submodule
|
||||
;
|
||||
in
|
||||
{
|
||||
options.services.gatus = {
|
||||
enable = mkEnableOption "Gatus";
|
||||
|
||||
package = mkPackageOption pkgs "gatus" { };
|
||||
|
||||
configFile = mkOption {
|
||||
type = path;
|
||||
default = settingsFormat.generate "gatus.yaml" cfg.settings;
|
||||
defaultText = literalExpression ''
|
||||
let settingsFormat = pkgs.formats.yaml { }; in settingsFormat.generate "gatus.yaml" cfg.settings;
|
||||
'';
|
||||
description = ''
|
||||
Path to the Gatus configuration file.
|
||||
Overrides any configuration made using the `settings` option.
|
||||
'';
|
||||
};
|
||||
|
||||
environmentFile = mkOption {
|
||||
type = nullOr path;
|
||||
default = null;
|
||||
description = ''
|
||||
File to load as environment file.
|
||||
Environmental variables from this file can be interpolated in the configuration file using `''${VARIABLE}`.
|
||||
This is useful to avoid putting secrets into the nix store.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
options = {
|
||||
web.port = mkOption {
|
||||
type = int;
|
||||
default = 8080;
|
||||
description = ''
|
||||
The TCP port to serve the Gatus service at.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = { };
|
||||
|
||||
example = literalExpression ''
|
||||
{
|
||||
web.port = 8080;
|
||||
endpoints = [{
|
||||
name = "website";
|
||||
url = "https://twin.sh/health";
|
||||
interval = "5m";
|
||||
conditions = [
|
||||
"[STATUS] == 200"
|
||||
"[BODY].status == UP"
|
||||
"[RESPONSE_TIME] < 300"
|
||||
];
|
||||
}];
|
||||
}
|
||||
'';
|
||||
|
||||
description = ''
|
||||
Configuration for Gatus.
|
||||
Supported options can be found at the [docs](https://gatus.io/docs).
|
||||
'';
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to open the firewall for the Gatus web interface.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.gatus = {
|
||||
description = "Automated developer-oriented status page";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
User = "gatus";
|
||||
Group = "gatus";
|
||||
Type = "simple";
|
||||
Restart = "on-failure";
|
||||
ExecStart = getExe cfg.package;
|
||||
StateDirectory = "gatus";
|
||||
SyslogIdentifier = "gatus";
|
||||
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
|
||||
};
|
||||
|
||||
environment = {
|
||||
GATUS_CONFIG_PATH = cfg.configFile;
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ cfg.settings.web.port ];
|
||||
};
|
||||
|
||||
meta.maintainers = with maintainers; [ pizzapim ];
|
||||
}
|
|
@ -367,6 +367,7 @@ in {
|
|||
mimir = handleTest ./mimir.nix {};
|
||||
gancio = handleTest ./gancio.nix {};
|
||||
garage = handleTest ./garage {};
|
||||
gatus = runTest ./gatus.nix;
|
||||
gemstash = handleTest ./gemstash.nix {};
|
||||
geoserver = runTest ./geoserver.nix;
|
||||
gerrit = handleTest ./gerrit.nix {};
|
||||
|
|
34
nixos/tests/gatus.nix
Normal file
34
nixos/tests/gatus.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
name = "gatus";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ pizzapim ];
|
||||
|
||||
nodes.machine =
|
||||
{ ... }:
|
||||
{
|
||||
services.gatus = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
web.port = 8080;
|
||||
metrics = true;
|
||||
|
||||
endpoints = [
|
||||
{
|
||||
name = "metrics";
|
||||
url = "http://localhost:8080/metrics";
|
||||
interval = "1s";
|
||||
conditions = [
|
||||
"[STATUS] == 200"
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("gatus.service")
|
||||
machine.succeed("curl -s http://localhost:8080/metrics | grep go_info")
|
||||
'';
|
||||
}
|
|
@ -1,4 +1,9 @@
|
|||
{ lib, buildGoModule, fetchFromGitHub }:
|
||||
{
|
||||
lib,
|
||||
buildGoModule,
|
||||
fetchFromGitHub,
|
||||
nixosTests,
|
||||
}:
|
||||
|
||||
buildGoModule rec {
|
||||
pname = "gatus";
|
||||
|
@ -15,12 +20,15 @@ buildGoModule rec {
|
|||
|
||||
subPackages = [ "." ];
|
||||
|
||||
meta = with lib;
|
||||
{
|
||||
description = "Automated developer-oriented status page";
|
||||
homepage = "https://gatus.io";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ undefined-moe ];
|
||||
mainProgram = "gatus";
|
||||
};
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) gatus;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Automated developer-oriented status page";
|
||||
homepage = "https://gatus.io";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ undefined-moe ];
|
||||
mainProgram = "gatus";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue