diff --git a/modules/installer/tools/nixos-deploy-network/deploy.nix b/modules/installer/tools/nixos-deploy-network/deploy.nix index bf2f88b831a8..c060ce417562 100644 --- a/modules/installer/tools/nixos-deploy-network/deploy.nix +++ b/modules/installer/tools/nixos-deploy-network/deploy.nix @@ -70,11 +70,18 @@ let { name = configurationName; value = (import "${nixos}/lib/eval-config.nix" { inherit nixpkgs; - modules = [ configuration ]; + modules = + [ configuration + # Provide a default hostname and deployment target equal + # to the attribute name of the machine in the model. + { key = "set-default-hostname"; + networking.hostName = pkgs.lib.mkOverride 900 configurationName; + deployment.targetHost = pkgs.lib.mkOverride 900 configurationName; + } + ]; extraArgs = evaluateMachines network; }).config; } - ) (attrNames (network))) - ; + ) (attrNames (network))); configs = evaluateMachines network; in diff --git a/modules/misc/deployment.nix b/modules/misc/deployment.nix index eead0f40beca..91a0e9040dd1 100644 --- a/modules/misc/deployment.nix +++ b/modules/misc/deployment.nix @@ -4,15 +4,12 @@ with pkgs.lib; { options = { - - deployment = { - targetHost = mkOption { - default = config.networking.hostName; - description = '' - This option specifies a hostname or IP address which can be used by nixos-deploy-network - to execute remote deployment operations. - ''; - }; + deployment.targetHost = mkOption { + default = config.networking.hostName; + description = '' + This option specifies a hostname or IP address which can be used by nixos-deploy-network + to execute remote deployment operations. + ''; }; }; }