Allows us to see which derivations are being built in realtime. It is a bit of a hack, but it seems to work. We simply look at the environment of the child processes of nix-daemon (usually bash) and then look for the $name variable which should hold the current derivation being built. Needs root to be able to read the environ file of the different nix-daemon processes as they are owned by the nixbld* users. See: https://discourse.nixos.org/t/query-ongoing-builds/23486 Reviewed-by: Aleix Boné <abonerib@bsc.es>
		
			
				
	
	
		
			24 lines
		
	
	
		
			598 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			598 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
| { pkgs, config, lib, ... }:
 | |
| let
 | |
|   script = pkgs.runCommand "nix-daemon-exporter.sh" { }
 | |
|     ''
 | |
|       cp ${./nix-daemon-builds.sh} $out;
 | |
|       chmod +x $out
 | |
|     ''
 | |
|   ;
 | |
| in
 | |
| {
 | |
|   systemd.services.nix-daemon-exporter = {
 | |
|     description = "Daemon to export nix-daemon metrics";
 | |
|     path = [ pkgs.procps pkgs.ripgrep ];
 | |
|     wantedBy = [ "default.target" ];
 | |
|     serviceConfig = {
 | |
|       Type = "simple";
 | |
|       ExecStart = "${pkgs.socat}/bin/socat TCP4-LISTEN:9999,fork EXEC:${script}";
 | |
|       # Needed root to read the environment, potentially unsafe
 | |
|       User = "root";
 | |
|       Group = "root";
 | |
|     };
 | |
|   };
 | |
| }
 |