summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-04-29 22:53:11 -0500
committerWilliam A. Kennington III <william@wkennington.com>2014-08-28 13:35:35 -0700
commita6e6c85f06395a92062eb31753a8dd8f3b7e733c (patch)
treef2e0b290a27b7185e5a905e43109cc3f2334e95a /nixos/modules/system
parentfba9f641a8ed54c27b1d9fadbd2022d8e18ce180 (diff)
downloadnixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.tar
nixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.tar.gz
nixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.tar.bz2
nixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.tar.lz
nixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.tar.xz
nixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.tar.zst
nixlib-a6e6c85f06395a92062eb31753a8dd8f3b7e733c.zip
grub: Add support for detecting btrfs subvolumes
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/loader/grub/grub.nix2
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl7
2 files changed, 8 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix
index bc19dd8c62fa..581b76f8fb21 100644
--- a/nixos/modules/system/boot/loader/grub/grub.nix
+++ b/nixos/modules/system/boot/loader/grub/grub.nix
@@ -28,7 +28,7 @@ let
         extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout
         default devices fsIdentifier;
       path = (makeSearchPath "bin" [
-        pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils
+        pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfsProgs
       ]) + ":" + (makeSearchPath "sbin" [
         pkgs.mdadm pkgs.utillinux
       ]);
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl
index 2615bc3ae11e..814ae7e05f7c 100644
--- a/nixos/modules/system/boot/loader/grub/install-grub.pl
+++ b/nixos/modules/system/boot/loader/grub/install-grub.pl
@@ -111,6 +111,13 @@ sub GrubFs {
                     die "invalid fs identifier type\n";
                 }
             }
+            if ($fs->type eq "btrfs") {
+                $subvol = `mount | sed -n 's,^$fs->device on .*subvol=\([^,)]*\).*$,\1,p'`
+                if ($subvol eq "") {
+                    $subvol = `btrfs subvol get-default $fs->mount | sed -n 's,^.*path \([^ ]*\) .*$,\1,p'`
+                }
+                $path = "/$subvol";
+            }
         }
         if (not $search eq "") {
             $search = "search --set=drive$driveid " . $search;