Unverified Commit 15b82046 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge master into staging-next

parents 8ca315db 592d4ee6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5253,6 +5253,12 @@
    githubId = 2489598;
    name = "Felix Breidenstein";
  };
  flemzord = {
    email = "maxence@maireaux.fr";
    github = "flemzord";
    githubId = 1952914;
    name = "Maxence Maireaux";
  };
  flexagoon = {
    email = "flexagoon@pm.me";
    github = "flexagoon";
+2 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ In addition to numerous new and updated packages, this release has the following

- [ivpn](https://www.ivpn.net/), a secure, private VPN with fast WireGuard connections. Available as [services.ivpn](#opt-services.ivpn.enable).

- [vmalert](https://victoriametrics.com/), an alerting engine for VictoriaMetrics. Available as [services.vmalert](#opt-services.vmalert.enable).

- [jellyseerr](https://github.com/Fallenbagel/jellyseerr), a web-based requests manager for Jellyfin, forked from Overseerr. Available as [services.jellyseerr](#opt-services.jellyseerr.enable).

- [kavita](https://kavitareader.com), a self-hosted digital library. Available as [services.kavita](options.html#opt-services.kavita.enable).
+1 −0
Original line number Diff line number Diff line
@@ -777,6 +777,7 @@
  ./services/monitoring/uptime-kuma.nix
  ./services/monitoring/uptime.nix
  ./services/monitoring/vmagent.nix
  ./services/monitoring/vmalert.nix
  ./services/monitoring/vnstat.nix
  ./services/monitoring/zabbix-agent.nix
  ./services/monitoring/zabbix-proxy.nix
+136 −0
Original line number Diff line number Diff line
{ config, pkgs, lib, ... }: with lib;
let
  cfg = config.services.vmalert;

  format = pkgs.formats.yaml {};

  confOpts = concatStringsSep " \\\n" (mapAttrsToList mkLine (filterAttrs (_: v: v != false) cfg.settings));
  confType = with types;
    let
      valueType = oneOf [ bool int path str ];
    in
    attrsOf (either valueType (listOf valueType));

  mkLine = key: value:
    if value == true then "-${key}"
    else if isList value then concatMapStringsSep " " (v: "-${key}=${escapeShellArg (toString v)}") value
    else "-${key}=${escapeShellArg (toString value)}"
  ;
in
{
  # interface
  options.services.vmalert = {
    enable = mkEnableOption (mdDoc "vmalert");

    package = mkOption {
      type = types.package;
      default = pkgs.victoriametrics;
      defaultText = "pkgs.victoriametrics";
      description = mdDoc ''
        The VictoriaMetrics derivation to use.
      '';
    };

    settings = mkOption {
      type = types.submodule {
        freeformType = confType;
        options = {

          "datasource.url" = mkOption {
            type = types.nonEmptyStr;
            example = "http://localhost:8428";
            description = mdDoc ''
              Datasource compatible with Prometheus HTTP API.
            '';
          };

          "notifier.url" = mkOption {
            type = with types; listOf nonEmptyStr;
            default = [];
            example = [ "http://127.0.0.1:9093" ];
            description = mdDoc ''
              Prometheus Alertmanager URL. List all Alertmanager URLs if it runs in the cluster mode to ensure high availability.
            '';
          };

          "rule" = mkOption {
            type = with types; listOf path;
            description = mdDoc ''
              Path to the files with alerting and/or recording rules.

              ::: {.note}
              Consider using the {option}`services.vmalert.rules` option as a convenient alternative for declaring rules
              directly in the `nix` language.
              :::
            '';
          };

        };
      };
      default = { };
      example = {
        "datasource.url" = "http://localhost:8428";
        "datasource.disableKeepAlive" = true;
        "datasource.showURL" = false;
        "rule" = [
          "http://<some-server-addr>/path/to/rules"
          "dir/*.yaml"
        ];
      };
      description = mdDoc ''
        `vmalert` configuration, passed via command line flags. Refer to
        <https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmalert/README.md#configuration>
        for details on supported values.
      '';
    };

    rules = mkOption {
      type = format.type;
      default = {};
      example = {
        group = [
          { name = "TestGroup";
            rules = [
              { alert = "ExampleAlertAlwaysFiring";
                expr = ''
                  sum by(job)
                  (up == 1)
                '';
              }
            ];
          }
        ];
      };
      description = mdDoc ''
        A list of the given alerting or recording rules against configured `"datasource.url"` compatible with
        Prometheus HTTP API for `vmalert` to execute. Refer to
        <https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmalert/README.md#rules>
        for details on supported values.
      '';
    };
  };

  # implementation
  config = mkIf cfg.enable {

    environment.etc."vmalert/rules.yml".source = format.generate "rules.yml" cfg.rules;

    services.vmalert.settings.rule = [
      "/etc/vmalert/rules.yml"
    ];

    systemd.services.vmalert = {
      description = "vmalert service";
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];
      reloadTriggers = [ config.environment.etc."vmalert/rules.yml".source ];

      serviceConfig = {
        DynamicUser = true;
        Restart = "on-failure";
        ExecStart = "${cfg.package}/bin/vmalert ${confOpts}";
        ExecReload = ''${pkgs.coreutils}/bin/kill -SIGHUP "$MAINPID"'';
      };
    };
  };
}
+16 −12
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
, stdenvNoCC
, buildDotnetModule
, fetchFromGitHub
, fetchpatch
, dotnetCorePackages
, gtk4
, libadwaita
@@ -10,20 +9,19 @@
, wrapGAppsHook4
, glib
, shared-mime-info
, python3
, desktop-file-utils
, gdk-pixbuf
, blueprint-compiler
}:

buildDotnetModule rec {
  pname = "denaro";
  version = "2023.2.2";
  version = "2023.5.0";

  src = fetchFromGitHub {
    owner = "nlogozzo";
    repo = "NickvisionMoney";
    owner = "NickvisionApps";
    repo = "Denaro";
    rev = version;
    hash = "sha256-B84uzJ+B7kGU+O2tuObrIFCvgUfszLd1VU7F5tL90bU=";
    hash = "sha256-kYN4Qm4xxOUkMi3twyVkT9PBnauDp7aenYy0YXzwKNA=";
  };

  dotnet-sdk = dotnetCorePackages.sdk_7_0;
@@ -42,15 +40,19 @@ buildDotnetModule rec {
    wrapGAppsHook4
    glib # For glib-compile-resources
    shared-mime-info # For update-mime-database
    python3
    desktop-file-utils
    gdk-pixbuf # Fixes icon missing in envs where GDK_PIXBUF_MODULE_FILE is not set
    blueprint-compiler
  ];

  buildInputs = [ gtk4 libadwaita ]; # Used by blueprint-compiler

  # Denaro switches installation tool frequently (bash -> just -> cake)
  # For maintainability, let's do it ourselves
  postInstall = ''
    sh NickvisionMoney.GNOME/install_extras.sh $out
    desktop-file-edit $out/share/applications/org.nickvision.money.desktop \
      --set-key=Exec --set-value=$out/bin/NickvisionMoney.GNOME
    substituteInPlace NickvisionMoney.Shared/org.nickvision.money.desktop.in --replace '@EXEC@' "NickvisionMoney.GNOME"
    install -Dm444 NickvisionMoney.Shared/Resources/org.nickvision.money.svg -t $out/share/icons/hicolor/scalable/apps/
    install -Dm444 NickvisionMoney.Shared/Resources/org.nickvision.money-symbolic.svg -t $out/share/icons/hicolor/symbolic/apps/
    install -Dm444 NickvisionMoney.Shared/org.nickvision.money.desktop.in -T $out/share/applications/org.nickvision.money.desktop
  '';

  runtimeDeps = [
@@ -59,6 +61,8 @@ buildDotnetModule rec {
    glib # Fixes "Could not retrieve parent type - is the typeid valid?"
  ];

  passthru.updateScript = ./update.sh;

  meta = with lib; {
    description = "Personal finance manager for GNOME";
    homepage = "https://github.com/nlogozzo/NickvisionMoney";
Loading