From deb6cce4bbb3fa90f8039b9f2a9bacdf72a9b663 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Thu, 28 Apr 2011 11:02:58 +0000 Subject: [PATCH] Adapted deploy-network to accept multiple network configurations which are zipped together. With this you can run the tool like this: $ nixos-deploy-network network1.nix network2.nix svn path=/nixos/trunk/; revision=27028 --- .../tools/nixos-deploy-network/deploy.nix | 14 ++++++++------ .../nixos-deploy-network/nixos-deploy-network.sh | 11 +++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/installer/tools/nixos-deploy-network/deploy.nix b/modules/installer/tools/nixos-deploy-network/deploy.nix index c060ce417562..6f9dd434d2fd 100644 --- a/modules/installer/tools/nixos-deploy-network/deploy.nix +++ b/modules/installer/tools/nixos-deploy-network/deploy.nix @@ -1,6 +1,6 @@ { nixos ? /etc/nixos/nixos , nixpkgs ? /etc/nixos/nixpkgs -, networkExpr +, networkExprs , targetProperty ? "targetHost" }: @@ -8,9 +8,11 @@ let pkgs = import nixpkgs {}; inherit (builtins) attrNames getAttr listToAttrs; - inherit (pkgs.lib) concatMapStrings; + inherit (pkgs.lib) concatMapStrings zipAttrs; - network = import networkExpr; + networks = map (networkExpr: import networkExpr) networkExprs; + + network = zipAttrs networks; generateRollbackSucceededPhase = network: configs: concatMapStrings (configurationName: @@ -65,14 +67,14 @@ let evaluateMachines = network: listToAttrs (map (configurationName: let - configuration = getAttr configurationName network; + modules = getAttr configurationName network; in { name = configurationName; value = (import "${nixos}/lib/eval-config.nix" { inherit nixpkgs; modules = - [ configuration - # Provide a default hostname and deployment target equal + modules ++ + [ # 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; diff --git a/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh b/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh index f1668ce780db..28580e2f49de 100644 --- a/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh +++ b/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh @@ -4,7 +4,7 @@ showUsage() { - echo "Usage: $0 network_expr" + echo "Usage: $0 network_expr [network_expr2 ...]" echo "Options:" echo echo "--show-trace Shows an output trace" @@ -55,13 +55,16 @@ fi if [ "$@" = "" ] then - echo "ERROR: A network Nix expression must be specified!" >&2 + echo "ERROR: At least one network Nix expression must be specified!" >&2 exit 1 else - networkExpr=$(readlink -f $@) + for i in $@ + do + networkExprs="$networkExprs \"$(readlink -f $i)\"" + done fi # Deploy the network -vms=`nix-build $NIXOS/modules/installer/tools/nixos-deploy-network/deploy.nix --argstr networkExpr $networkExpr --argstr nixos $NIXOS $showTraceArg $noOutLinkArg` +vms=`nix-build $NIXOS/modules/installer/tools/nixos-deploy-network/deploy.nix --arg networkExprs "[ $networkExprs ]" --argstr nixos $NIXOS $showTraceArg $noOutLinkArg` $vms/bin/deploy-systems