export flake information into monitoring

This commit is contained in:
Jörg Thalheim 2022-11-22 13:49:56 +01:00
parent 3e3ad0dea6
commit bfaa502523
2 changed files with 21 additions and 1 deletions

View file

@ -47,6 +47,7 @@
inherit (self.inputs.nixpkgs.lib) nixosSystem;
common = [
self.inputs.sops-nix.nixosModules.sops
{ _module.args.inputs = self.inputs; }
];
in {
"build01.nix-community.org" = nixosSystem {

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, inputs, ... }:
let
asGB = size: toString (size * 1024 * 1024);
@ -42,5 +42,24 @@ in
Restart = "on-failure";
};
# inputs == flake inputs in configurations.nix
environment.etc = let
inputsWithDate = lib.filterAttrs (_: input: input ? lastModified) inputs;
flakeAttrs = input: (lib.mapAttrsToList (n: v: ''${n}="${v}"'')
(lib.filterAttrs (n: v: (builtins.typeOf v) == "string") input));
lastModified = name: input: ''
flake_input_last_modified{input="${name}",${lib.concatStringsSep "," (flakeAttrs input)}} ${toString input.lastModified}
'';
in {
"flake-inputs.prom" = {
mode = "0555";
text = ''
# HELP flake_registry_last_modified Last modification date of flake input in unixtime
# TYPE flake_input_last_modified gauge
${lib.concatStringsSep "\n" (lib.mapAttrsToList lastModified inputsWithDate)}
'';
};
};
users.groups.trusted = { };
}