diff --git a/flake.nix b/flake.nix index 29184a6..8fc0395 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { diff --git a/roles/nix-daemon.nix b/roles/nix-daemon.nix index 0f906cf..af404f5 100644 --- a/roles/nix-daemon.nix +++ b/roles/nix-daemon.nix @@ -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 = { }; }