mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
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`
This commit is contained in:
parent
00487b5a87
commit
611b8c4472
1 changed files with 7 additions and 1 deletions
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue