From 4755811a12c11b5ed6f6ccd6036526d5869d9b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Mon, 10 Jun 2019 21:12:01 +0200 Subject: [PATCH] nixos-generate-config: add support for bcache Add "bcache" to boot.initrd.availableKernelModules if a bcache device is detected. This fixes a problem I've had one too many times: I install NixOS and forget to add "bcache", resulting in an unbootable machine (until fixed with Live CD). Now NixOS will do it for me. --- nixos/modules/installer/tools/nixos-generate-config.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index b7e5b99a9e01..0ccdac30d915 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -258,6 +258,11 @@ foreach my $path (glob "/sys/class/{block,mmc_host}/*") { } } +# Add bcache module, if needed. +my @bcacheDevices = glob("/dev/bcache*"); +if (scalar @bcacheDevices > 0) { + push @initrdAvailableKernelModules, "bcache"; +} my $virt = `systemd-detect-virt`; chomp $virt;