Commit 611b8c44 authored by Artturin's avatar Artturin
Browse files

nixos/nixos-generate-config: fix specifying --root /mnt --dir adir

it should save to `$PWD/adir` instead of `/mnt/adir`
and --dir adir should save to `$PWD/adir` instead of `/adir`
parent 00487b5a
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
        $n++;
        $rootDir = $ARGV[$n];
        die "$0: ‘--root’ requires an argument\n" unless defined $rootDir;
        die "$0: no need to specify `/` with `--root`, it is the default\n" if $rootDir eq "/";
        $rootDir =~ s/\/*$//; # remove trailing slashes
        $rootDir = File::Spec->rel2abs($rootDir); # resolve absolute path
    }
@@ -617,7 +618,12 @@ EOF
if ($showHardwareConfig) {
    print STDOUT $hwConfig;
} else {
    if ($outDir eq "/etc/nixos") {
        $outDir = "$rootDir$outDir";
    } else {
        $outDir = File::Spec->rel2abs($outDir);
        $outDir =~ s/\/*$//; # remove trailing slashes
    }

    my $fn = "$outDir/hardware-configuration.nix";
    print STDERR "writing $fn...\n";