diff --git a/flake.lock b/flake.lock index 7ba588a..e22a09f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "nixos-exporter": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1672682716, + "narHash": "sha256-JCoUwtUoIR6Xtdx0Cdo6q6MbwX4V2XuL6TL6+KV0Grk=", + "ref": "refs/heads/main", + "rev": "698f36518d9ddf1ac773fac0a2781d668bb44916", + "revCount": 3, + "type": "git", + "url": "https://git.clerie.de/clerie/nixos-exporter.git" + }, + "original": { + "type": "git", + "url": "https://git.clerie.de/clerie/nixos-exporter.git" + } + }, "nixpkgs": { "locked": { "lastModified": 1667142599, @@ -18,6 +38,7 @@ }, "root": { "inputs": { + "nixos-exporter": "nixos-exporter", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 097aa09..6ee58f4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,12 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixos-exporter = { + url = "git+https://git.clerie.de/clerie/nixos-exporter.git"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, ... }: let + outputs = { self, nixpkgs, nixos-exporter, ... }: let pkgs = import nixpkgs { overlays = [ (import ./pkgs/overlay.nix) @@ -16,6 +20,14 @@ system = "x86_64-linux"; modules = [ ./configuration/common + ({ ... }: { + nixpkgs.overlays = [ + (_: _: { + inherit (nixos-exporter.packages.${system}) + nixos-exporter; + }) + ]; + }) (./hosts + "/${name}/configuration.nix") ]; }; diff --git a/modules/monitoring/default.nix b/modules/monitoring/default.nix index d346ff3..c6d4c40 100644 --- a/modules/monitoring/default.nix +++ b/modules/monitoring/default.nix @@ -76,5 +76,28 @@ in ip_protocol_fallback: false ''; }; + + users.users."nixos-exporter" = { + isSystemUser = true; + group = "nixos-exporter"; + }; + + users.groups."nixos-exporter" = {}; + + systemd.services."prometheus-nixos-exporter" = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = "/tmp"; + RuntimeDirectory = "prometheus-nixos-exporter"; + User = "nixos-exporter"; + Group = "nixos-exporter"; + ExecStart = '' + ${pkgs.nixos-exporter}/bin/nixos-exporter + ''; + }; + }; }; }