Fix ugly systemd-boot entries

This commit is contained in:
2025-11-28 16:02:14 +01:00
parent 53541a590b
commit a3d5410004

View File

@@ -1,5 +1,5 @@
# Systemd-boot configuration for NixOS # Systemd-boot configuration for NixOS
{ pkgs, ... }: { pkgs, config, ... }:
{ {
boot = { boot = {
bootspec.enable = true; bootspec.enable = true;
@@ -9,6 +9,22 @@
enable = true; enable = true;
consoleMode = "auto"; consoleMode = "auto";
configurationLimit = 5; 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; tmp.cleanOnBoot = true;