diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index a70c9daff23..efb250c081d 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -131,6 +131,8 @@ foreach my $path (glob "/sys/bus/pci/devices/*") { pciCheck $path; } +push @attrs, "services.xserver.videoDrivers = [ \"$videoDriver\" ];" if $videoDriver; + # Idem for USB devices. @@ -172,7 +174,6 @@ foreach my $path (glob "/sys/bus/usb/devices/*") { # Add the modules for all block devices. - foreach my $path (glob "/sys/class/block/*") { my $module; if (-e "$path/device/driver/module") { @@ -183,11 +184,6 @@ foreach my $path (glob "/sys/class/block/*") { } -if ($videoDriver) { - push @attrs, "services.xserver.videoDrivers = [ \"$videoDriver\" ];"; -} - - # Check if we're a VirtualBox guest. If so, enable the guest # additions. my $dmi = `@dmidecode@/sbin/dmidecode`; @@ -196,6 +192,16 @@ if ($dmi =~ /Manufacturer: innotek/) { } +# Generate the list of swap devices. +my @swaps = read_file("/proc/swaps"); +shift @swaps; +my @swapDevices; +foreach my $swap (@swaps) { + $swap =~ /^(\S+)\s/; + push @swapDevices, "{ device = \"$1\"; }"; +} + + # Generate the hardware configuration file. sub removeDups { @@ -220,19 +226,21 @@ sub toNixExpr { sub multiLineList { my $indent = shift; - my $res = ""; - $res = "\n" if scalar @_ > 0; + return "[ ]" if !@_; + $res = "\n${indent}[ "; + my $first = 1; foreach my $s (@_) { - $res .= "$indent$s\n"; + $res .= "$indent " if !$first; + $first = 0; + $res .= "$s\n"; } + $res .= "$indent]"; return $res; } my $initrdKernelModules = toNixExpr(removeDups @initrdKernelModules); my $kernelModules = toNixExpr(removeDups @kernelModules); my $modulePackages = toNixExpr(removeDups @modulePackages); -my $attrs = multiLineList(" ", removeDups @attrs); -my $imports = multiLineList(" ", removeDups @imports); my $fn = "$outDir/hardware-configuration.nix"; print STDERR "writing $fn...\n"; @@ -245,16 +253,19 @@ write_file($fn, <