Skip to content

Commit

Permalink
nixos/install-grub: include child configs in grub menu
Browse files Browse the repository at this point in the history
Add configs listed under the fine-tune subdirectory to the grub menu.
Use specified configuration name for the entry if available.
  • Loading branch information
vmandela committed Aug 26, 2018
1 parent 99dc074 commit 54783c3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions nixos/modules/system/boot/loader/grub/install-grub.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 54783c3

Please sign in to comment.