about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorVenkateswara Rao Mandela <venkat.mandela@gmail.com>2018-08-19 23:17:21 +0530
committerVenkateswara Rao Mandela <venkat.mandela@gmail.com>2019-07-11 17:38:25 +0530
commit7f363b034e3db9d08969c261ef2044c5948c94a0 (patch)
treefeac0dbca83070ad89f2b3ba454d1045ffb83765 /nixos/modules/system
parent0ad1b80a3b1536c4b373dd1b5fcf42a3e41bbbd8 (diff)
downloadnixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.tar
nixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.tar.gz
nixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.tar.bz2
nixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.tar.lz
nixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.tar.xz
nixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.tar.zst
nixlib-7f363b034e3db9d08969c261ef2044c5948c94a0.zip
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.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl
index a36b3c180eb4..a09c5dc47618 100644
--- a/nixos/modules/system/boot/loader/grub/install-grub.pl
+++ b/nixos/modules/system/boot/loader/grub/install-grub.pl
@@ -407,6 +407,29 @@ addEntry("NixOS - Default", $defaultConfig);
 
 $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;