From 54783c3e9aec054ea188f861433a0356b4bef8af Mon Sep 17 00:00:00 2001 From: Venkateswara Rao Mandela Date: Sun, 19 Aug 2018 23:17:21 +0530 Subject: [PATCH] nixos/install-grub: include child configs in grub menu Add configs listed under the fine-tune subdirectory to the grub menu. Use specified configuration name for the entry if available. --- .../system/boot/loader/grub/install-grub.pl | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index d1ff6e6bf5256b..ca901d07ec0582 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -398,6 +398,29 @@ sub addEntry { $conf .= "$extraEntries\n" unless $extraEntriesBeforeNixOS; +# Find all the children of the current default configuration +# Do not search for grand children +my @links = sort (glob "$defaultConfig/fine-tune/*"); +foreach my $link (@links) { + + my $entryName = ""; + + my $cfgName = readFile("$link/configuration-name"); + + my $date = strftime("%F", localtime(lstat($link)->mtime)); + my $version = + -e "$link/nixos-version" + ? readFile("$link/nixos-version") + : basename((glob(dirname(Cwd::abs_path("$link/kernel")) . "/lib/modules/*"))[0]); + + if ($cfgName) { + $entryName = $cfgName; + } else { + $entryName = "($date - $version)"; + } + addEntry("NixOS - $entryName", $link); +} + my $grubBootPath = $grubBoot->path; # extraEntries could refer to @bootRoot@, which we have to substitute $conf =~ s/\@bootRoot\@/$grubBootPath/g;