3
0
Fork 0
forked from mirrors/nixpkgs

nixos-generate-config: Add --no-filesystems flag.

This is to get back the old behavior of nixos-hardware-scan, which
didn't include fileSystems and swapDevices.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2013-10-23 15:55:27 +02:00
parent 03e1178f80
commit a546069ad3
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961
2 changed files with 19 additions and 3 deletions

View file

@ -110,6 +110,14 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>--no-filesystems</option></term>
<listitem>
<para>Omit everything concerning file system information
(which includes swap devices) from the hardware configuration.</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>

View file

@ -23,6 +23,7 @@ sub uniq {
my $outDir = "/etc/nixos";
my $rootDir = ""; # = /
my $force = 0;
my $noFilesystems = 0;
for (my $n = 0; $n < scalar @ARGV; $n++) {
my $arg = $ARGV[$n];
@ -43,6 +44,9 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
elsif ($arg eq "--force") {
$force = 1;
}
elsif ($arg eq "--no-filesystems") {
$noFilesystems = 1;
}
else {
die "$0: unrecognized argument $arg\n";
}
@ -338,6 +342,12 @@ 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, <<EOF);
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
@ -350,9 +360,7 @@ write_file($fn, <<EOF);
boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ];
boot.kernelModules = [$kernelModules ];
boot.extraModulePackages = [$modulePackages ];
${fileSystems} swapDevices = ${\multiLineList(" ", @swapDevices)};
$fsAndSwap
nix.maxJobs = $cpus;
${\join "", (map { " $_\n" } (uniq @attrs))}}
EOF