Author: sandervanderburg
Date: Mon Dec 6 22:02:37 2010
New Revision: 25019
URL: https://svn.nixos.org/websvn/nix/?rev=25019&sc=1
Log:
- nixos-deploy-network no longer uses an infrastructure model => use
nixpkgs.system and deployment.hostname instead
- implemented --no-out-link option so that invoking these tools from scripts
leave no garbage behind
- some misc. cleanups
Modified:
nixos/trunk/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh
nixos/trunk/modules/installer/tools/nixos-deploy-network/deploy.nix
nixos/trunk/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh
Modified: nixos/trunk/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh
==============================================================================
--- nixos/trunk/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh
Mon Dec 6 19:09:40 2010 (r25018)
+++ nixos/trunk/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh
Mon Dec 6 22:02:37 2010 (r25019)
@@ -4,18 +4,18 @@
showUsage()
{
- echo "Usage: $0 -n network_expr -i infrastructure_expr"
+ echo "Usage: $0 network_expr"
echo "Options:"
echo
- echo "-n,--network Network Nix expression which captures properties
of machines in the network"
- echo "--use-backdoor Indicates that the backdoor must be enabled so
that the VMs can be accessed through a UNIX domain socket"
- echo "--show-trace Shows the output trace"
- echo "-h,--help Shows the usage of this command"
+ echo "--use-backdoor Indicates that the backdoor must be enabled so that
the VMs can be accessed through a UNIX domain socket"
+ echo "--no-out-link Do not create a 'result' symlink"
+ echo "--show-trace Shows the output trace"
+ echo "-h,--help Shows the usage of this command"
}
# Parse valid argument options
-PARAMS=`getopt -n $0 -o n:h -l network:,use-backdoor,show-trace,help -- "$@"`
+PARAMS=`getopt -n $0 -o h -l use-backdoor,show-trace,help -- "$@"`
if [ $? != 0 ]
then
@@ -30,12 +30,12 @@
while [ "$1" != "--" ]
do
case "$1" in
- -n|--network)
- networkExpr=`readlink -f $2`
- ;;
--use-backdoor)
useBackdoorArg="--arg useBackdoor true"
;;
+ --no-out-link)
+ noOutLinkArg="--no-out-link"
+ ;;
--show-trace)
showTraceArg="--show-trace"
;;
@@ -48,19 +48,23 @@
shift
done
+shift
+
# Validate the given options
-if [ "$networkExpr" = "" ]
+if [ -z "$NIXOS" ]
then
- echo "ERROR: A network expression must be specified!" >&2
- exit 1
+ NIXOS=/etc/nixos/nixos
fi
-if [ -z "$NIXOS" ]
+if [ "$@" = "" ]
then
- NIXOS=/etc/nixos/nixos
+ echo "ERROR: A network expression must be specified!" >&2
+ exit 1
+else
+ networkExpr=$(readlink -f $@)
fi
# Build a network of VMs
-nix-build $NIXOS/modules/installer/tools/nixos-build-vms/build-vms.nix
--argstr networkExpr $networkExpr --argstr nixos $NIXOS --argstr nixpkgs
$NIXPKGS_ALL $useBackdoorArg $showTraceArg
+nix-build $NIXOS/modules/installer/tools/nixos-build-vms/build-vms.nix
--argstr networkExpr $networkExpr --argstr nixos $NIXOS --argstr nixpkgs
$NIXPKGS_ALL $useBackdoorArg $noOutLinkArg $showTraceArg
Modified: nixos/trunk/modules/installer/tools/nixos-deploy-network/deploy.nix
==============================================================================
--- nixos/trunk/modules/installer/tools/nixos-deploy-network/deploy.nix Mon Dec
6 19:09:40 2010 (r25018)
+++ nixos/trunk/modules/installer/tools/nixos-deploy-network/deploy.nix Mon Dec
6 22:02:37 2010 (r25019)
@@ -1,7 +1,6 @@
{ nixos ? /etc/nixos/nixos
, nixpkgs ? /etc/nixos/nixpkgs
, networkExpr
-, infrastructureExpr
, targetProperty ? "hostname"
}:
@@ -12,19 +11,17 @@
inherit (pkgs.lib) concatMapStrings;
network = import networkExpr;
- infrastructure = import infrastructureExpr;
- generateRollbackSucceededPhase = network: infrastructure: configs:
+ generateRollbackSucceededPhase = network: configs:
concatMapStrings (configurationName:
let
- infrastructureElement = getAttr configurationName infrastructure;
config = getAttr configurationName configs;
in
''
if [ "$rollback" != "$succeeded" ]
then
- ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
nix-env -p /nix/var/nix/profiles/system --rollback
- ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
+ ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)}
nix-env -p /nix/var/nix/profiles/system --rollback
+ ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)}
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
rollback=$((rollback + 1))
fi
@@ -32,33 +29,31 @@
) (attrNames network)
;
- generateDistributionPhase = network: infrastructure: configs:
+ generateDistributionPhase = network: configs:
concatMapStrings (configurationName:
let
- infrastructureElement = getAttr configurationName infrastructure;
config = getAttr configurationName configs;
in
''
- echo "=== copy system closure to ${getAttr targetProperty
infrastructureElement} ==="
- nix-copy-closure --to ${getAttr targetProperty infrastructureElement}
${config.system.build.toplevel}
+ echo "=== copy system closure to ${getAttr targetProperty
(config.deployment)} ==="
+ nix-copy-closure --to ${getAttr targetProperty (config.deployment)}
${config.system.build.toplevel}
''
) (attrNames network)
;
- generateActivationPhase = network: infrastructure: configs:
+ generateActivationPhase = network: configs:
concatMapStrings (configurationName:
let
- infrastructureElement = getAttr configurationName infrastructure;
config = getAttr configurationName configs;
in
''
- echo "=== activating system configuration on ${getAttr targetProperty
infrastructureElement} ==="
- ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
nix-env -p /nix/var/nix/profiles/system --set ${config.system.build.toplevel}
||
- (ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
nix-env -p /nix/var/nix/profiles/system --rollback; rollbackSucceeded)
+ echo "=== activating system configuration on ${getAttr targetProperty
(config.deployment)} ==="
+ ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env
-p /nix/var/nix/profiles/system --set ${config.system.build.toplevel} ||
+ (ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)}
nix-env -p /nix/var/nix/profiles/system --rollback; rollbackSucceeded)
- ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
/nix/var/nix/profiles/system/bin/switch-to-configuration switch ||
- ( ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
nix-env -p /nix/var/nix/profiles/system --rollback
- ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement}
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
+ ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)}
/nix/var/nix/profiles/system/bin/switch-to-configuration switch ||
+ ( ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)}
nix-env -p /nix/var/nix/profiles/system --rollback
+ ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)}
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
rollbackSucceeded
)
@@ -67,22 +62,21 @@
) (attrNames network)
;
- evaluateMachines = network: infrastructure:
+ evaluateMachines = network:
listToAttrs (map (configurationName:
let
configuration = getAttr configurationName network;
- system = (getAttr configurationName infrastructure).system;
in
{ name = configurationName;
value = (import "${nixos}/lib/eval-config.nix" {
- inherit nixpkgs system;
+ inherit nixpkgs;
modules = [ configuration ];
- extraArgs = evaluateMachines network infrastructure;
+ extraArgs = evaluateMachines network;
}).config; }
) (attrNames (network)))
;
- configs = evaluateMachines network infrastructure;
+ configs = evaluateMachines network;
in
pkgs.stdenv.mkDerivation {
name = "deploy-script";
@@ -100,18 +94,18 @@
rollbackSucceeded()
{
rollback=0
- ${generateRollbackSucceededPhase network infrastructure configs}
+ ${generateRollbackSucceededPhase network configs}
}
# Distribution phase
- ${generateDistributionPhase network infrastructure configs}
+ ${generateDistributionPhase network configs}
# Activation phase
succeeded=0
- ${generateActivationPhase network infrastructure configs}
+ ${generateActivationPhase network configs}
EOF
chmod +x $out/bin/deploy-systems
'';
Modified:
nixos/trunk/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh
==============================================================================
---
nixos/trunk/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh
Mon Dec 6 19:09:40 2010 (r25018)
+++
nixos/trunk/modules/installer/tools/nixos-deploy-network/nixos-deploy-network.sh
Mon Dec 6 22:02:37 2010 (r25019)
@@ -4,18 +4,17 @@
showUsage()
{
- echo "Usage: $0 -n network_expr -i infrastructure_expr"
+ echo "Usage: $0 network_expr"
echo "Options:"
echo
- echo "-n,--network Network Nix expression which captures properties
of machines in the network"
- echo "-i,--infrastructure Infrastructure Nix expression which captures
properties of machines in the network"
- echo "--show-trace Shows an output trace"
- echo "-h,--help Shows the usage of this command"
+ echo "--show-trace Shows an output trace"
+ echo "--no-out-link Do not create a 'result' symlink"
+ echo "-h,--help Shows the usage of this command"
}
# Parse valid argument options
-PARAMS=`getopt -n $0 -o n:i:h -l network:,infrastructure:,show-trace,help --
"$@"`
+PARAMS=`getopt -n $0 -o h -l show-trace,no-out-link,help -- "$@"`
if [ $? != 0 ]
then
@@ -30,15 +29,12 @@
while [ "$1" != "--" ]
do
case "$1" in
- -n|--network)
- networkExpr=`readlink -f $2`
- ;;
- -i|--infrastructure)
- infrastructureExpr=`readlink -f $2`
- ;;
--show-trace)
showTraceArg="--show-trace"
;;
+ --no-out-link)
+ noOutLinkArg="--no-out-link"
+ ;;
-h|--help)
showUsage
exit 0
@@ -48,27 +44,24 @@
shift
done
+shift
+
# Validate the given options
-if [ "$infrastructureExpr" = "" ]
+if [ -z "$NIXOS" ]
then
- echo "ERROR: A infrastructure expression must be specified!" >&2
- exit 1
+ NIXOS=/etc/nixos/nixos
fi
-if [ "$networkExpr" = "" ]
+if [ "$@" = "" ]
then
- echo "ERROR: A network expression must be specified!" >&2
+ echo "ERROR: A network Nix expression must be specified!" >&2
exit 1
-fi
-
-if [ -z "$NIXOS" ]
-then
- NIXOS=/etc/nixos/nixos
+else
+ networkExpr=$(readlink -f $@)
fi
# Deploy the network
-nix-build $NIXOS/modules/installer/tools/nixos-deploy-network/deploy.nix
--argstr networkExpr $networkExpr --argstr infrastructureExpr
$infrastructureExpr $showTraceArg
-./result/bin/deploy-systems
-rm -f result
+vms=`nix-build $NIXOS/modules/installer/tools/nixos-deploy-network/deploy.nix
--argstr networkExpr $networkExpr $showTraceArg $noOutLinkArg`
+$vms/bin/deploy-systems
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits