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:
parent
a61015cfa1
commit
deb6cce4bb
@ -1,6 +1,6 @@
|
|||||||
{ nixos ? /etc/nixos/nixos
|
{ nixos ? /etc/nixos/nixos
|
||||||
, nixpkgs ? /etc/nixos/nixpkgs
|
, nixpkgs ? /etc/nixos/nixpkgs
|
||||||
, networkExpr
|
, networkExprs
|
||||||
, targetProperty ? "targetHost"
|
, targetProperty ? "targetHost"
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -8,9 +8,11 @@ let
|
|||||||
pkgs = import nixpkgs {};
|
pkgs = import nixpkgs {};
|
||||||
|
|
||||||
inherit (builtins) attrNames getAttr listToAttrs;
|
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:
|
generateRollbackSucceededPhase = network: configs:
|
||||||
concatMapStrings (configurationName:
|
concatMapStrings (configurationName:
|
||||||
@ -65,14 +67,14 @@ let
|
|||||||
evaluateMachines = network:
|
evaluateMachines = network:
|
||||||
listToAttrs (map (configurationName:
|
listToAttrs (map (configurationName:
|
||||||
let
|
let
|
||||||
configuration = getAttr configurationName network;
|
modules = getAttr configurationName network;
|
||||||
in
|
in
|
||||||
{ name = configurationName;
|
{ name = configurationName;
|
||||||
value = (import "${nixos}/lib/eval-config.nix" {
|
value = (import "${nixos}/lib/eval-config.nix" {
|
||||||
inherit nixpkgs;
|
inherit nixpkgs;
|
||||||
modules =
|
modules =
|
||||||
[ configuration
|
modules ++
|
||||||
# Provide a default hostname and deployment target equal
|
[ # Provide a default hostname and deployment target equal
|
||||||
# to the attribute name of the machine in the model.
|
# to the attribute name of the machine in the model.
|
||||||
{ key = "set-default-hostname";
|
{ key = "set-default-hostname";
|
||||||
networking.hostName = pkgs.lib.mkOverride 900 configurationName;
|
networking.hostName = pkgs.lib.mkOverride 900 configurationName;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
showUsage()
|
showUsage()
|
||||||
{
|
{
|
||||||
echo "Usage: $0 network_expr"
|
echo "Usage: $0 network_expr [network_expr2 ...]"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo
|
echo
|
||||||
echo "--show-trace Shows an output trace"
|
echo "--show-trace Shows an output trace"
|
||||||
@ -55,13 +55,16 @@ fi
|
|||||||
|
|
||||||
if [ "$@" = "" ]
|
if [ "$@" = "" ]
|
||||||
then
|
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
|
exit 1
|
||||||
else
|
else
|
||||||
networkExpr=$(readlink -f $@)
|
for i in $@
|
||||||
|
do
|
||||||
|
networkExprs="$networkExprs \"$(readlink -f $i)\""
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deploy the network
|
# 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
|
$vms/bin/deploy-systems
|
||||||
|
Loading…
Reference in New Issue
Block a user