Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2df2efc52668
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4f65275babc5
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Jun 16, 2019

  1. 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.
    
    (cherry picked from commit 4755811)
    bjornfor committed Jun 16, 2019
    Copy the full SHA
    1fd2806 View commit details
  2. nixos-generate-config: don't generate swapDevices for *files*

    Up until now, the output has been the same for swap devices and swap
    files:
    
      { device = "/var/swapfile"; }
    
    Whereas for swap *files* it's easier to manage them declaratively in
    configuration.nix:
    
      { device = "/var/swapfile"; size = 8192; }
    
    (NixOS will create the swapfile, and later resize it, if the size
    attribute is changed.)
    
    With the assumption that swap files are specified in configuration.nix,
    it's silly to output them to hardware-configuration.nix.
    
    (cherry picked from commit 9e45f6f)
    bjornfor committed Jun 16, 2019
    Copy the full SHA
    f8ebfd5 View commit details
  3. nixos-generate-config: add dm-snapshot module if LVM is detected

    Without this, the system becomes unbootable if the user creates a LVM
    snapshot and reboots.
    
    Fixes #33646
    
    (The same kind of problem was fixed in RHEL a few years back:
    https://bugzilla.redhat.com/show_bug.cgi?id=1287940)
    
    (cherry picked from commit 4213e48)
    bjornfor committed Jun 16, 2019
    Copy the full SHA
    4f65275 View commit details
Showing with 25 additions and 4 deletions.
  1. +25 −4 nixos/modules/installer/tools/nixos-generate-config.pl
29 changes: 25 additions & 4 deletions nixos/modules/installer/tools/nixos-generate-config.pl
Original file line number Diff line number Diff line change
@@ -258,6 +258,16 @@ sub usbCheck {
}
}

# Add bcache module, if needed.
my @bcacheDevices = glob("/dev/bcache*");
if (scalar @bcacheDevices > 0) {
push @initrdAvailableKernelModules, "bcache";
}

# Prevent unbootable systems if LVM snapshots are present at boot time.
if (`lsblk -o TYPE` =~ "lvm") {
push @initrdKernelModules, "dm-snapshot";
}

my $virt = `systemd-detect-virt`;
chomp $virt;
@@ -319,10 +329,19 @@ sub findStableDevPath {
if (@swaps) {
shift @swaps;
foreach my $swap (@swaps) {
$swap =~ /^(\S+)\s/;
next unless -e $1;
my $dev = findStableDevPath $1;
push @swapDevices, "{ device = \"$dev\"; }";
my @fields = split ' ', $swap;
my $swapFilename = $fields[0];
my $swapType = $fields[1];
next unless -e $swapFilename;
my $dev = findStableDevPath $swapFilename;
if ($swapType =~ "partition") {
push @swapDevices, "{ device = \"$dev\"; }";
} elsif ($swapType =~ "file") {
# swap *files* are more likely specified in configuration.nix, so
# ignore them here.
} else {
die "Unsupported swap type: $swapType\n";
}
}
}

@@ -497,6 +516,7 @@ sub multiLineList {
}

my $initrdAvailableKernelModules = toNixStringList(uniq @initrdAvailableKernelModules);
my $initrdKernelModules = toNixStringList(uniq @initrdKernelModules);
my $kernelModules = toNixStringList(uniq @kernelModules);
my $modulePackages = toNixList(uniq @modulePackages);

@@ -516,6 +536,7 @@ sub multiLineList {
imports =${\multiLineList(" ", @imports)};
boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ];
boot.initrd.kernelModules = [$initrdKernelModules ];
boot.kernelModules = [$kernelModules ];
boot.extraModulePackages = [$modulePackages ];
$fsAndSwap