Archived
1
0
forked from rarias/bscpkgs

Keep a log over time with the config commits

This commit is contained in:
2023-09-02 23:49:41 +02:00
parent a2c5fe1f5e
commit a242ddd39c
2 changed files with 24 additions and 8 deletions

18
m/common/rev.nix Normal file
View 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
'';
}