From f182fdf6ed3acf820a5f619eda9bffee1ecd1c46 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 23 Oct 2013 16:42:34 +0200 Subject: nixos-generate-config: Add --show-hardware-config. So, we get the old behaviour of nixos-hardware-scane if we run the following command: nixos-generate-config --no-filesystems --show-hardware-config This allows to use scripts in order to fetch NixOS specific hardware information, without the need to duplicate code elsewhere. Signed-off-by: aszlig --- .../installer/tools/nixos-generate-config.pl | 47 +++++++++++++--------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl') diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index a4d22410806..c6ac72e113b 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -24,6 +24,7 @@ my $outDir = "/etc/nixos"; my $rootDir = ""; # = / my $force = 0; my $noFilesystems = 0; +my $showHardwareConfig = 0; for (my $n = 0; $n < scalar @ARGV; $n++) { my $arg = $ARGV[$n]; @@ -47,6 +48,9 @@ for (my $n = 0; $n < scalar @ARGV; $n++) { elsif ($arg eq "--no-filesystems") { $noFilesystems = 1; } + elsif ($arg eq "--show-hardware-config") { + $showHardwareConfig = 1; + } else { die "$0: unrecognized argument ‘$arg’\n"; } @@ -336,19 +340,13 @@ my $initrdAvailableKernelModules = toNixExpr(uniq @initrdAvailableKernelModules) my $kernelModules = toNixExpr(uniq @kernelModules); my $modulePackages = toNixExpr(uniq @modulePackages); -$outDir = "$rootDir$outDir"; - -my $fn = "$outDir/hardware-configuration.nix"; -print STDERR "writing $fn...\n"; -mkpath($outDir, 0, 0755); - my $fsAndSwap = ""; if (!$noFilesystems) { $fsAndSwap = "\n${fileSystems} "; $fsAndSwap .= "swapDevices =" . multiLineList(" ", @swapDevices) . ";\n"; } -write_file($fn, <= 3.10 boot.kernelPackages = pkgs.linuxPackages_3_10; EOF - } else { - $bootLoaderConfig = <