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
This commit is contained in:
Sander van der Burg 2011-04-28 11:02:58 +00:00
parent a61015cfa1
commit deb6cce4bb
2 changed files with 15 additions and 10 deletions

View File

@ -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;

View File

@ -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