diff options
Diffstat (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl')
-rw-r--r-- | nixos/modules/installer/tools/nixos-generate-config.pl | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 93a348f2717..eadaae6715b 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -22,7 +22,7 @@ sub uniq { sub runCommand { my ($cmd) = @_; - open FILE, "$cmd 2>/dev/null |" or die "Failed to execute: $cmd\n"; + open FILE, "$cmd 2>&1 |" or die "Failed to execute: $cmd\n"; my @ret = <FILE>; close FILE; return ($?, @ret); @@ -148,7 +148,7 @@ sub pciCheck { $device eq "0x4331" || $device eq "0x43a0" || $device eq "0x43b1" ) ) { - push @modulePackages, "config.boot.kernelPackages.broadcom_sta"; + push @modulePackages, "\${config.boot.kernelPackages.broadcom_sta}"; push @kernelModules, "wl"; } @@ -235,7 +235,7 @@ chomp $virt; # Check if we're a VirtualBox guest. If so, enable the guest # additions. if ($virt eq "oracle") { - push @attrs, "services.virtualbox.enable = true;" + push @attrs, "services.virtualboxGuest.enable = true;" } @@ -311,10 +311,13 @@ foreach my $fs (read_file("/proc/self/mountinfo")) { # Maybe this is a bind-mount of a filesystem we saw earlier? if (defined $fsByDev{$fields[2]}) { - my $path = $fields[3]; $path = "" if $path eq "/"; - my $base = $fsByDev{$fields[2]}; - $base = "" if $base eq "/"; - $fileSystems .= <<EOF; + # Make sure this isn't a btrfs subvolume + my ($status, @msg) = runCommand("btrfs subvol show $rootDir$mountPoint"); + if (join("", @msg) =~ /ERROR:/) { + my $path = $fields[3]; $path = "" if $path eq "/"; + my $base = $fsByDev{$fields[2]}; + $base = "" if $base eq "/"; + $fileSystems .= <<EOF; fileSystems.\"$mountPoint\" = { device = \"$base$path\"; fsType = \"none\"; @@ -322,7 +325,8 @@ foreach my $fs (read_file("/proc/self/mountinfo")) { }; EOF - next; + next; + } } $fsByDev{$fields[2]} = $mountPoint; @@ -344,19 +348,29 @@ EOF } } - # Is this a btrfs filesystem? - if ($fsType eq "btrfs") { - my ($status, @info) = runCommand("btrfs subvol show $rootDir$mountPoint"); - if ($status != 0) { - die "Failed to retreive subvolume info for $mountPoint"; - } - my @subvols = join("", @info) =~ m/Name:[ \t\n]*([^ \t\n]*)/; - if ($#subvols > 0) { - die "Btrfs subvol name for $mountPoint listed multiple times in mount\n" - } elsif ($#subvols == 0) { - push @extraOptions, "subvol=$subvols[0]"; - } - } + # Is this a btrfs filesystem? + if ($fsType eq "btrfs") { + my ($status, @id_info) = runCommand("btrfs subvol show $rootDir$mountPoint"); + if ($status != 0 || join("", @msg) =~ /ERROR:/) { + die "Failed to retreive subvolume info for $mountPoint\n"; + } + my @ids = join("", @id_info) =~ m/Object ID:[ \t\n]*([^ \t\n]*)/; + if ($#ids > 0) { + die "Btrfs subvol name for $mountPoint listed multiple times in mount\n" + } elsif ($#ids == 0) { + my ($status, @path_info) = runCommand("btrfs subvol list $rootDir$mountPoint"); + if ($status != 0) { + die "Failed to find $mountPoint subvolume id from btrfs\n"; + } + my @paths = join("", @path_info) =~ m/ID $ids[0] [^\n]* path ([^\n]*)/; + if ($#paths > 0) { + die "Btrfs returned multiple paths for a single subvolume id, mountpoint $mountPoint\n"; + } elsif ($#paths != 0) { + die "Btrfs did not return a path for the subvolume at $mountPoint\n"; + } + push @extraOptions, "subvol=$paths[0]"; + } + } # Emit the filesystem. $fileSystems .= <<EOF; @@ -416,7 +430,7 @@ my $hwConfig = <<EOF; # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: { imports =${\multiLineList(" ", @imports)}; @@ -477,7 +491,7 @@ EOF $bootLoaderConfig # networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # Select internationalisation properties. # i18n = { @@ -486,6 +500,9 @@ $bootLoaderConfig # defaultLocale = "en_US.UTF-8"; # }; + # Set your time zone. + # time.timeZone = "Europe/Amsterdam"; + # List packages installed in system profile. To search by name, run: # \$ nix-env -qaP | grep wget # environment.systemPackages = with pkgs; [ |