diff --git a/pkgs/tools/virtualization/nixos-container/nixos-container.pl b/pkgs/tools/virtualization/nixos-container/nixos-container.pl index a4b6f11654e8..6d28c2a4d615 100755 --- a/pkgs/tools/virtualization/nixos-container/nixos-container.pl +++ b/pkgs/tools/virtualization/nixos-container/nixos-container.pl @@ -18,13 +18,13 @@ umask 0022; sub showHelp { print < [--system-path ] [--config ] [--ensure-unique-name] [--auto-start] + nixos-container create [--nixos-path ] [--system-path ] [--config ] [--ensure-unique-name] [--auto-start] nixos-container destroy nixos-container start nixos-container stop nixos-container kill [--signal ] nixos-container status - nixos-container update [--config ] + nixos-container update [--config ] [--nixos-path ] nixos-container login nixos-container root-login nixos-container run -- args... @@ -35,6 +35,7 @@ EOF } my $systemPath; +my $nixosPath; my $ensureUniqueName = 0; my $autoStart = 0; my $extraConfig; @@ -45,8 +46,9 @@ GetOptions( "ensure-unique-name" => \$ensureUniqueName, "auto-start" => \$autoStart, "system-path=s" => \$systemPath, - "config=s" => \$extraConfig, "signal=s" => \$signal + "nixos-path=s" => \$nixosPath, + "config=s" => \$extraConfig ) or exit 1; my $action = $ARGV[0] or die "$0: no action specified\n"; @@ -158,11 +160,12 @@ if ($action eq "create") { } else { mkpath("$root/etc/nixos", 0, 0755); + my $nixenvF = $nixosPath // ""; my $nixosConfigFile = "$root/etc/nixos/configuration.nix"; writeNixOSConfig $nixosConfigFile; system("nix-env", "-p", "$profileDir/system", - "-I", "nixos-config=$nixosConfigFile", "-f", "", + "-I", "nixos-config=$nixosConfigFile", "-f", "$nixenvF", "--set", "-A", "system") == 0 or die "$0: failed to build initial container configuration\n"; } @@ -272,8 +275,9 @@ elsif ($action eq "update") { # configuration.nix. writeNixOSConfig $nixosConfigFile if (defined $extraConfig && $extraConfig ne ""); + my $nixenvF = $nixosPath // ""; system("nix-env", "-p", "$profileDir/system", - "-I", "nixos-config=$nixosConfigFile", "-f", "", + "-I", "nixos-config=$nixosConfigFile", "-f", "$nixenvF", "--set", "-A", "system") == 0 or die "$0: failed to build container configuration\n";