diff --git a/nixos/systemd-boot.nix b/nixos/systemd-boot.nix index 7cdaafd..21d5bfb 100644 --- a/nixos/systemd-boot.nix +++ b/nixos/systemd-boot.nix @@ -1,5 +1,5 @@ # Systemd-boot configuration for NixOS -{ pkgs, ... }: +{ pkgs, config, ... }: { boot = { bootspec.enable = true; @@ -9,6 +9,22 @@ enable = true; consoleMode = "auto"; configurationLimit = 5; + + extraInstallCommands = '' + ENTRIES="${config.boot.loader.efi.efiSysMountPoint}/loader/entries" + PROFILES="/nix/var/nix/profiles" + + for file in "$ENTRIES"/nixos-generation-*.conf; do + generation=$(${pkgs.coreutils}/bin/basename "$file" | ${pkgs.gnugrep}/bin/grep -o -E '[0-9]+') + timestamp=$(${pkgs.coreutils}/bin/stat -c %y "$PROFILES/system-$generation-link" 2>/dev/null | ${pkgs.coreutils}/bin/cut -d. -f1) + + if [ -z "$timestamp" ]; then + timestamp="Unknown Date" + fi + + ${pkgs.gnused}/bin/sed -i "s/^version .*/version Generation $generation - $timestamp/" "$file" + done + ''; }; }; tmp.cleanOnBoot = true;