From f182fdf6ed3acf820a5f619eda9bffee1ecd1c46 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 23 Oct 2013 16:42:34 +0200 Subject: [PATCH] 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 --- .../doc/manual/man-nixos-generate-config.xml | 9 ++++ .../installer/tools/nixos-generate-config.pl | 49 +++++++++++-------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/nixos/doc/manual/man-nixos-generate-config.xml b/nixos/doc/manual/man-nixos-generate-config.xml index 0771753f6893..e4fba4a40a97 100644 --- a/nixos/doc/manual/man-nixos-generate-config.xml +++ b/nixos/doc/manual/man-nixos-generate-config.xml @@ -118,6 +118,15 @@ + + + + Don't generate configuration.nix or + hardware-configuration.nix and print the + hardware configuration to stdout only. + + + diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index a4d224108061..c6ac72e113be 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 = <