* nixos-hardware-scan: detect if we're in a VirtualBox guest and

enable the guest additions in that case.

svn path=/nixos/trunk/; revision=33133
This commit is contained in:
Eelco Dolstra 2012-03-16 01:57:23 +00:00
parent 53bd25c7fa
commit f4903be57e
2 changed files with 13 additions and 4 deletions

View File

@ -8,6 +8,7 @@ my @attrs = ();
my @kernelModules = ();
my @initrdKernelModules = ();
my @modulePackages = ();
my @requires = ("<nixos/modules/installer/scan/not-detected.nix>");
sub debug {
@ -182,6 +183,14 @@ if ($videoDriver) {
}
# Check if we're a VirtualBox guest. If so, enable the guest
# additions.
my $dmi = `@dmidecode@/sbin/dmidecode`;
if ($dmi =~ /Manufacturer: innotek/) {
push @attrs, "services.virtualbox.enable = true;"
}
# Generate the configuration file.
sub removeDups {
@ -218,6 +227,8 @@ my $initrdKernelModules = toNixExpr(removeDups @initrdKernelModules);
my $kernelModules = toNixExpr(removeDups @kernelModules);
my $modulePackages = toNixExpr(removeDups @modulePackages);
my $attrs = multiLineList(" ", removeDups @attrs);
my $requires = multiLineList(" ", removeDups @requires);
print <<EOF ;
# This is a generated file. Do not modify!
@ -225,9 +236,7 @@ print <<EOF ;
{ config, pkgs, ... }:
{
require = [
<nixos/modules/installer/scan/not-detected.nix>
];
require = [$requires ];
boot.initrd.kernelModules = [$initrdKernelModules ];
boot.kernelModules = [$kernelModules ];

View File

@ -48,7 +48,7 @@ let
nixosHardwareScan = makeProg {
name = "nixos-hardware-scan";
src = ./nixos-hardware-scan.pl;
inherit (pkgs) perl;
inherit (pkgs) perl dmidecode;
};
nixosOption = makeProg {