Keep a log over time with the config commits
This commit is contained in:
		
							parent
							
								
									a2c5fe1f5e
								
							
						
					
					
						commit
						a242ddd39c
					
				| @ -11,6 +11,7 @@ | |||||||
|     ./ssh.nix |     ./ssh.nix | ||||||
|     ./users.nix |     ./users.nix | ||||||
|     ./watchdog.nix |     ./watchdog.nix | ||||||
|  |     ./rev.nix | ||||||
|   ]; |   ]; | ||||||
| 
 | 
 | ||||||
|   nixpkgs.overlays = [ |   nixpkgs.overlays = [ | ||||||
| @ -18,6 +19,11 @@ | |||||||
|     (import ../../pkgs/overlay.nix) |     (import ../../pkgs/overlay.nix) | ||||||
|   ]; |   ]; | ||||||
| 
 | 
 | ||||||
|  |   system.configurationRevision = | ||||||
|  |     if theFlake ? rev | ||||||
|  |     then theFlake.rev | ||||||
|  |     else throw ("Refusing to build from a dirty Git tree!"); | ||||||
|  | 
 | ||||||
|   nix.nixPath = [ |   nix.nixPath = [ | ||||||
|     "nixpkgs=${nixpkgs}" |     "nixpkgs=${nixpkgs}" | ||||||
|     "bscpkgs=${bscpkgs}" |     "bscpkgs=${bscpkgs}" | ||||||
| @ -28,14 +34,6 @@ | |||||||
|   nix.registry.bscpkgs.flake = bscpkgs; |   nix.registry.bscpkgs.flake = bscpkgs; | ||||||
|   nix.registry.jungle.flake = theFlake; |   nix.registry.jungle.flake = theFlake; | ||||||
| 
 | 
 | ||||||
|   system.configurationRevision = |  | ||||||
|     if theFlake ? rev |  | ||||||
|     then theFlake.rev |  | ||||||
|     else throw ("Refusing to build from a dirty Git tree!"); |  | ||||||
| 
 |  | ||||||
|   # Save the commit of the config in /etc/nixos/config.rev |  | ||||||
|   environment.etc."nixos/config.rev".text = system.configurationRevision; |  | ||||||
| 
 |  | ||||||
|   environment.systemPackages = with pkgs; [ |   environment.systemPackages = with pkgs; [ | ||||||
|     vim wget git htop tmux pciutils tcpdump ripgrep nix-index nixos-option |     vim wget git htop tmux pciutils tcpdump ripgrep nix-index nixos-option | ||||||
|     nix-diff ipmitool freeipmi ethtool lm_sensors ix cmake gnumake file tree |     nix-diff ipmitool freeipmi ethtool lm_sensors ix cmake gnumake file tree | ||||||
|  | |||||||
							
								
								
									
										18
									
								
								m/common/rev.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								m/common/rev.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | |||||||
|  | { theFlake, ... }: | ||||||
|  | 
 | ||||||
|  | let | ||||||
|  |   rev = if theFlake ? rev then theFlake.rev | ||||||
|  |     else throw ("Refusing to build from a dirty Git tree!"); | ||||||
|  | in { | ||||||
|  |   # Save the commit of the config in /etc/configrev | ||||||
|  |   environment.etc.configrev.text = rev + "\n"; | ||||||
|  | 
 | ||||||
|  |   # Keep a log with the config over time | ||||||
|  |   system.activationScripts.configRevLog.text = '' | ||||||
|  |     BOOTED=$(cat /run/booted-system/etc/configrev 2>/dev/null || echo unknown) | ||||||
|  |     CURRENT=$(cat /run/current-system/etc/configrev 2>/dev/null || echo unknown) | ||||||
|  |     NEXT=${rev} | ||||||
|  |     DATENOW=$(date --iso-8601=seconds) | ||||||
|  |     echo "$DATENOW booted=$BOOTED current=$CURRENT next=$NEXT" >> /var/configrev.log | ||||||
|  |   ''; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user