Merge branch 'master' of git://github.com/NixOS/nixos into x-updates

This commit is contained in:
Vladimír Čunát 2013-06-15 08:43:45 +02:00
commit d85ec960d1
10 changed files with 87 additions and 49 deletions

View File

@ -9,8 +9,8 @@
<xsl:template match="logfile">
<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="treebits.js" />
<link rel="stylesheet" href="logfile.css" type="text/css" />
<title>Log File</title>
@ -37,18 +37,18 @@
</xsl:for-each>
</ul>
</xsl:if>
</body>
</html>
</xsl:template>
<xsl:template match="nest">
<!-- The tree should be collapsed by default if all children are
unimportant or if the header is unimportant. -->
<xsl:variable name="collapsed" select="not(./head[@expanded]) and count(.//*[@error]) = 0"/>
<xsl:variable name="style"><xsl:if test="$collapsed">display: none;</xsl:if></xsl:variable>
<xsl:if test="line|nest">
@ -60,19 +60,19 @@
</a>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select='head'/>
<!-- Be careful to only generate <ul>s if there are <li>s, otherwise its malformed. -->
<xsl:if test="line|nest">
<ul class='nesting' style="{$style}">
<xsl:for-each select='line|nest'>
<!-- Is this the last line? If so, mark it as such so that it
can be rendered differently. -->
<xsl:variable name="class"><xsl:choose><xsl:when test="position() != last()">line</xsl:when><xsl:otherwise>lastline</xsl:otherwise></xsl:choose></xsl:variable>
<li class='{$class}'>
<span class='lineconn' />
<span class='linebody'>
@ -82,10 +82,10 @@
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="head|line">
<code>
<xsl:if test="@error">
@ -101,7 +101,7 @@
<xsl:if test="@type = 'serial'">
<xsl:attribute name="class">serial</xsl:attribute>
</xsl:if>
<xsl:if test="@machine">
<xsl:choose>
<xsl:when test="@type = 'serial'">
@ -112,7 +112,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:choose>
<xsl:when test="@image">
<a href="{@image}"><xsl:apply-templates/></a>
@ -120,16 +120,16 @@
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:choose>
</code>
</xsl:template>
<xsl:template match="storeref">
<em class='storeref'>
<span class='popup'><xsl:apply-templates/></span>
<span class='elided'>/...</span><xsl:apply-templates select='name'/><xsl:apply-templates select='path'/>
</em>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>

View File

@ -53,8 +53,6 @@ rec {
xsltproc --output $out/log.html ${./test-driver/log2html.xsl} $out/log.xml
ln -s ${./test-driver/logfile.css} $out/logfile.css
ln -s ${./test-driver/treebits.js} $out/treebits.js
ln -s ${pkgs.jquery_ui}/js/jquery.min.js $out/
ln -s ${pkgs.jquery_ui}/js/jquery-ui.min.js $out/
touch $out/nix-support/hydra-build-products
echo "report testlog $out log.html" >> $out/nix-support/hydra-build-products

View File

@ -4,14 +4,16 @@ import os
import sys
import time
import argparse
import charon.util
from charon import deployment
import nixops.util
from nixops import deployment
from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType
import boto.ec2
parser = argparse.ArgumentParser(description='Create an EBS-backed NixOS AMI')
parser.add_argument('--region', dest='region', required=True, help='EC2 region')
parser.add_argument('--keep', dest='keep', action='store_true', help='Keep Charon machine after use')
parser.add_argument('--region', dest='region', required=True, help='EC2 region to create the image in')
parser.add_argument('--keep', dest='keep', action='store_true', help='Keep NixOps machine after use')
parser.add_argument('--hvm', dest='hvm', action='store_true', help='Create HVM image')
parser.add_argument('--key', dest='key_name', action='store_true', help='Keypair used for HVM instance creation', default="rob")
args = parser.parse_args()
instance_type = "cc1.4xlarge" if args.hvm else "m1.small"
@ -67,7 +69,7 @@ m.run_command("nix-channel --update")
m.run_command("nixos-rebuild switch")
version = m.run_command("nixos-version", capture_stdout=True).replace('"', '').rstrip()
print >> sys.stderr, "NixOS version is {0}".format(version)
m.run_command("cp -f $(nix-instantiate --find-file nixos/modules/virtualisation/amazon-config.nix) /mnt/etc/nixos/configuration.nix")
m.upload_file("./amazon-base-config.nix", "/mnt/etc/nixos/configuration.nix")
m.run_command("nixos-install")
if args.hvm:
m.run_command('cp /mnt/nix/store/*-grub-0.97*/lib/grub/i386-pc/* /mnt/boot/grub')
@ -98,24 +100,24 @@ volume = m._conn.get_all_volumes([], filters={'attachment.instance-id': m.resour
if args.hvm:
instance = m._conn.run_instances( image_id="ami-6a9e4503"
, instance_type=instance_type
, key_name=key_name
, key_name=args.key_name
, placement=m.zone
, security_groups=["eelco-test"]).instances[0]
charon.util.check_wait(lambda: instance.update() == 'running', max_tries=120)
nixops.util.check_wait(lambda: instance.update() == 'running', max_tries=120)
instance.stop()
charon.util.check_wait(lambda: instance.update() == 'stopped', max_tries=120)
nixops.util.check_wait(lambda: instance.update() == 'stopped', max_tries=120)
old_root_volume = m._conn.get_all_volumes([], filters={'attachment.instance-id': instance.id, 'attachment.device': "/dev/sda1"})[0]
old_root_volume.detach()
volume.detach()
charon.util.check_wait(lambda: volume.update() == 'available', max_tries=120)
charon.util.check_wait(lambda: old_root_volume.update() == 'available', max_tries=120)
nixops.util.check_wait(lambda: volume.update() == 'available', max_tries=120)
nixops.util.check_wait(lambda: old_root_volume.update() == 'available', max_tries=120)
volume.attach(instance.id, '/dev/sda1')
charon.util.check_wait(lambda: volume.update() == 'in-use', max_tries=120)
nixops.util.check_wait(lambda: volume.update() == 'in-use', max_tries=120)
ami_id = m._conn.create_image(instance.id, ami_name, description)
time.sleep(5)
image = m._conn.get_all_images([ami_id])[0]
charon.util.check_wait(lambda: image.update() == 'available', max_tries=120)
nixops.util.check_wait(lambda: image.update() == 'available', max_tries=120)
instance.terminate()
else:
@ -123,7 +125,7 @@ else:
snapshot = volume.create_snapshot(description=description)
print >> sys.stderr, "created snapshot {0}".format(snapshot.id)
charon.util.check_wait(check, max_tries=120)
nixops.util.check_wait(check, max_tries=120)
m._conn.create_tags([snapshot.id], {'Name': ami_name})
@ -160,7 +162,6 @@ print >> sys.stderr, "making image public..."
image = m._conn.get_all_images(image_ids=[ami_id])[0]
image.set_launch_permissions(user_ids=[], group_names=["all"])
# Do a test deployment to make sure that the AMI works.
f = open("ebs-test.nix", "w")
f.write(
@ -190,11 +191,30 @@ test_depl.name = "ebs-creator-test"
test_depl.nix_exprs = [os.path.abspath("./ebs-test.nix")]
test_depl.deploy(create_only=True)
test_depl.machines['machine'].run_command("nixos-version")
if args.hvm:
image_type = 'hvm'
else:
image_type = 'ebs'
# Log the AMI ID.
f = open("{0}.{1}.ami-id".format(args.region, image_type), "w")
f.write("{0}".format(ami_id))
f.close()
for dest in [ 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1']:
if args.region != dest:
print >> sys.stderr, "copying image from region {0} to {1}".format(args.region, dest)
conn = boto.ec2.connect_to_region(dest)
copy_image = conn.copy_image(args.region, ami_id, ami_name, description=None, client_token=None)
# Log the AMI ID.
f = open("{0}.{1}.ami-id".format(dest, image_type), "w")
f.write("{0}".format(copy_image.image_id))
f.close()
if not args.keep:
test_depl.destroy_resources()
test_depl.delete()
# Log the AMI ID.
f = open("{0}.ebs.ami-id".format(args.region), "w")
f.write("{0}".format(ami_id))
f.close()

View File

@ -1,7 +1,7 @@
#! /bin/sh -e
nixos=$(nix-instantiate --find-file nixos)
export NIXOS_CONFIG=$nixos/modules/virtualisation/amazon-config.nix
export NIXOS_CONFIG=$(dirname $(readlink -f $0))/amazon-base-config.nix
version=$(nix-instantiate --eval-only '<nixos>' -A config.system.nixosVersion | sed s/'"'//g)
echo "NixOS version is $version"

View File

@ -54,7 +54,7 @@ in
options = {
environment.nix = mkOption {
default = pkgs.nixUnstable;
default = pkgs.nix;
merge = mergeOneOption;
description = ''
This option specifies the Nix package instance to use throughout the system.
@ -220,7 +220,7 @@ in
};
binaryCaches = mkOption {
default = [ http://nixos.org/binary-cache ];
default = [ http://cache.nixos.org/ ];
type = types.listOf types.string;
description = ''
List of binary cache URLs used to obtain pre-built binaries

View File

@ -34,6 +34,8 @@ let
''}
'';
useLocalPostgres = cfg.dbServer == "localhost" || cfg.dbServer == "";
in
{
@ -51,7 +53,10 @@ in
services.zabbixServer.dbServer = mkOption {
default = "localhost";
description = "Hostname or IP address of the database server.";
description = ''
Hostname or IP address of the database server.
Use an empty string ("") to use peer authentication.
'';
};
services.zabbixServer.dbPassword = mkOption {
@ -65,7 +70,7 @@ in
config = mkIf cfg.enable {
services.postgresql.enable = cfg.dbServer == "localhost";
services.postgresql.enable = useLocalPostgres;
users.extraUsers = singleton
{ name = "zabbix";
@ -77,7 +82,7 @@ in
{ description = "Zabbix Server";
wantedBy = [ "multi-user.target" ];
after = optional (cfg.dbServer == "localhost") "postgresql.service";
after = optional useLocalPostgres "postgresql.service";
preStart =
''
@ -88,8 +93,8 @@ in
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
${pkgs.postgresql}/bin/createdb --owner zabbix zabbix || true
cat ${pkgs.zabbix.server}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
cat ${pkgs.zabbix.server}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
cat ${pkgs.zabbix.server}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
cat ${pkgs.zabbix.server}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
touch "${libDir}/db-created"
fi
'';
@ -100,6 +105,7 @@ in
serviceConfig.Type = "forking";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.PIDFile = pidFile;
};
};

View File

@ -52,6 +52,8 @@ in
mkdir -m 0755 -p /var/db/nscd
'';
restartTriggers = [ config.environment.etc.hosts.source ];
serviceConfig =
{ ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${./nscd.conf}";
Type = "forking";

View File

@ -93,7 +93,7 @@ with pkgs.lib;
[Service]
Environment=TERM=linux
Environment=LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
ExecStart=@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login %I 115200,38400,9600
ExecStart=@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login %I 115200,57600,38400,9600
Type=idle
Restart=always
RestartSec=0

View File

@ -11,10 +11,11 @@ let
# we could generate zabbix.conf.php declaratively.
zabbixPHP = pkgs.runCommand "${pkgs.zabbix.server.name}-php" {}
''
cp -rs ${pkgs.zabbix.server}/share/zabbix/php $out
cp -rs ${pkgs.zabbix.server}/share/zabbix/php "$out"
chmod -R u+w $out
#rm -rf $out/conf
ln -s ${config.stateDir}/zabbix.conf.php $out/conf/zabbix.conf.php
ln -s "${if config.configFile == null
then "${config.stateDir}/zabbix.conf.php"
else config.configFile}" "$out/conf/zabbix.conf.php"
'';
in
@ -27,6 +28,7 @@ in
''
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
'';
extraConfig = ''
@ -57,6 +59,16 @@ in
";
};
configFile = pkgs.lib.mkOption {
default = null;
type = with pkgs.lib.types; nullOr path;
description = ''
The configuration file (zabbix.conf.php) which contains the database
connection settings. If not set, the configuration settings will created
by the web installer.
'';
};
stateDir = pkgs.lib.mkOption {
default = "/var/lib/zabbix/frontend";
description = "

View File

@ -75,7 +75,7 @@ let
{ services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
services.httpd.servedDirs = singleton
{ urlPath = "/binary-cache";
{ urlPath = "/";
dir = "/tmp/channel";
};
@ -123,7 +123,7 @@ let
# Allow the machine to talk to the fake nixos.org.
$machine->succeed(
"rm /etc/hosts",
"echo 192.168.1.1 nixos.org > /etc/hosts",
"echo 192.168.1.1 nixos.org cache.nixos.org > /etc/hosts",
"ifconfig eth1 up 192.168.1.2",
);