@@ -43,7 +43,11 @@ sub runCommand {
4343if (-e " /etc/nixos-generate-config.conf" ) {
4444 my $cfg = new Config::IniFiles -file => " /etc/nixos-generate-config.conf" ;
4545 $outDir = $cfg -> val(" Defaults" , " Directory" ) // $outDir ;
46- $rootDir = $cfg -> val(" Defaults" , " RootDirectory" ) // $rootDir ;
46+ if (defined $cfg -> val(" Defaults" , " RootDirectory" )) {
47+ $rootDir = $cfg -> val(" Defaults" , " RootDirectory" );
48+ $rootDir =~ s /\/ *$// ; # remove trailing slashes
49+ $rootDir = File::Spec-> rel2abs($rootDir ); # resolve absolute path
50+ }
4751 $kernel = $cfg -> val(" Defaults" , " Kernel" ) // $kernel ;
4852}
4953
@@ -62,6 +66,8 @@ sub runCommand {
6266 $rootDir = $ARGV [$n ];
6367 die " $0 : ‘--root’ requires an argument\n " unless defined $rootDir ;
6468 die " $0 : no need to specify `/` with `--root`, it is the default\n " if $rootDir eq " /" ;
69+ $rootDir =~ s /\/ *$// ; # remove trailing slashes
70+ $rootDir = File::Spec-> rel2abs($rootDir ); # resolve absolute path
6571 }
6672 elsif ($arg eq " --force" ) {
6773 $force = 1;
@@ -85,8 +91,6 @@ sub runCommand {
8591 }
8692}
8793
88- $rootDir =~ s /\/ *$// ; # remove trailing slashes
89- $rootDir = File::Spec-> rel2abs($rootDir ); # resolve absolute path
9094die " $0 : invalid kernel: '$kernel '" unless $kernel eq " lts" || $kernel eq " latest" ;
9195
9296my @attrs = ();
0 commit comments