mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00
nixos-generate-config: add --flake option
Co-authored-by: éclairevoyant <848000+eclairevoyant@users.noreply.github.com>
This commit is contained in:
parent
29c58cf78d
commit
1606ea91b4
6 changed files with 84 additions and 4 deletions
|
@ -35,6 +35,7 @@ my $outDir = "/etc/nixos";
|
|||
my $rootDir = ""; # = /
|
||||
my $force = 0;
|
||||
my $noFilesystems = 0;
|
||||
my $flake = 0;
|
||||
my $showHardwareConfig = 0;
|
||||
|
||||
for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||
|
@ -64,6 +65,9 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
|||
elsif ($arg eq "--show-hardware-config") {
|
||||
$showHardwareConfig = 1;
|
||||
}
|
||||
elsif ($arg eq "--flake") {
|
||||
$flake = 1;
|
||||
}
|
||||
else {
|
||||
die "$0: unrecognized argument ‘$arg’\n";
|
||||
}
|
||||
|
@ -661,6 +665,19 @@ if ($showHardwareConfig) {
|
|||
mkpath($outDir, 0, 0755);
|
||||
write_file($fn, $hwConfig);
|
||||
|
||||
$fn = "$outDir/flake.nix";
|
||||
if ($flake) {
|
||||
if ($force || ! -e $fn) {
|
||||
print STDERR "writing $fn...\n";
|
||||
mkpath($outDir, 0, 0755);
|
||||
write_file($fn, <<EOF);
|
||||
@flake@
|
||||
EOF
|
||||
} else {
|
||||
print STDERR "warning: not overwriting existing $fn\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Generate a basic configuration.nix, unless one already exists.
|
||||
$fn = "$outDir/configuration.nix";
|
||||
if ($force || ! -e $fn) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue