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"> <xsl:template match="logfile">
<html> <html>
<head> <head>
<script type="text/javascript" src="jquery.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="jquery-ui.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" /> <script type="text/javascript" src="treebits.js" />
<link rel="stylesheet" href="logfile.css" type="text/css" /> <link rel="stylesheet" href="logfile.css" type="text/css" />
<title>Log File</title> <title>Log File</title>
@ -37,18 +37,18 @@
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
</body> </body>
</html> </html>
</xsl:template> </xsl:template>
<xsl:template match="nest"> <xsl:template match="nest">
<!-- The tree should be collapsed by default if all children are <!-- The tree should be collapsed by default if all children are
unimportant or if the header is unimportant. --> unimportant or if the header is unimportant. -->
<xsl:variable name="collapsed" select="not(./head[@expanded]) and count(.//*[@error]) = 0"/> <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:variable name="style"><xsl:if test="$collapsed">display: none;</xsl:if></xsl:variable>
<xsl:if test="line|nest"> <xsl:if test="line|nest">
@ -60,19 +60,19 @@
</a> </a>
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
</xsl:if> </xsl:if>
<xsl:apply-templates select='head'/> <xsl:apply-templates select='head'/>
<!-- Be careful to only generate <ul>s if there are <li>s, otherwise its malformed. --> <!-- Be careful to only generate <ul>s if there are <li>s, otherwise its malformed. -->
<xsl:if test="line|nest"> <xsl:if test="line|nest">
<ul class='nesting' style="{$style}"> <ul class='nesting' style="{$style}">
<xsl:for-each select='line|nest'> <xsl:for-each select='line|nest'>
<!-- Is this the last line? If so, mark it as such so that it <!-- Is this the last line? If so, mark it as such so that it
can be rendered differently. --> 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> <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}'> <li class='{$class}'>
<span class='lineconn' /> <span class='lineconn' />
<span class='linebody'> <span class='linebody'>
@ -82,10 +82,10 @@
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="head|line"> <xsl:template match="head|line">
<code> <code>
<xsl:if test="@error"> <xsl:if test="@error">
@ -101,7 +101,7 @@
<xsl:if test="@type = 'serial'"> <xsl:if test="@type = 'serial'">
<xsl:attribute name="class">serial</xsl:attribute> <xsl:attribute name="class">serial</xsl:attribute>
</xsl:if> </xsl:if>
<xsl:if test="@machine"> <xsl:if test="@machine">
<xsl:choose> <xsl:choose>
<xsl:when test="@type = 'serial'"> <xsl:when test="@type = 'serial'">
@ -112,7 +112,7 @@
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:if> </xsl:if>
<xsl:choose> <xsl:choose>
<xsl:when test="@image"> <xsl:when test="@image">
<a href="{@image}"><xsl:apply-templates/></a> <a href="{@image}"><xsl:apply-templates/></a>
@ -120,16 +120,16 @@
<xsl:otherwise> <xsl:otherwise>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</code> </code>
</xsl:template> </xsl:template>
<xsl:template match="storeref"> <xsl:template match="storeref">
<em class='storeref'> <em class='storeref'>
<span class='popup'><xsl:apply-templates/></span> <span class='popup'><xsl:apply-templates/></span>
<span class='elided'>/...</span><xsl:apply-templates select='name'/><xsl:apply-templates select='path'/> <span class='elided'>/...</span><xsl:apply-templates select='name'/><xsl:apply-templates select='path'/>
</em> </em>
</xsl:template> </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 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/logfile.css} $out/logfile.css
ln -s ${./test-driver/treebits.js} $out/treebits.js 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 touch $out/nix-support/hydra-build-products
echo "report testlog $out log.html" >> $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 sys
import time import time
import argparse import argparse
import charon.util import nixops.util
from charon import deployment from nixops import deployment
from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType
import boto.ec2
parser = argparse.ArgumentParser(description='Create an EBS-backed NixOS AMI') parser = argparse.ArgumentParser(description='Create an EBS-backed NixOS AMI')
parser.add_argument('--region', dest='region', required=True, help='EC2 region') 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 Charon machine after use') 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('--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() args = parser.parse_args()
instance_type = "cc1.4xlarge" if args.hvm else "m1.small" 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") m.run_command("nixos-rebuild switch")
version = m.run_command("nixos-version", capture_stdout=True).replace('"', '').rstrip() version = m.run_command("nixos-version", capture_stdout=True).replace('"', '').rstrip()
print >> sys.stderr, "NixOS version is {0}".format(version) 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") m.run_command("nixos-install")
if args.hvm: if args.hvm:
m.run_command('cp /mnt/nix/store/*-grub-0.97*/lib/grub/i386-pc/* /mnt/boot/grub') 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: if args.hvm:
instance = m._conn.run_instances( image_id="ami-6a9e4503" instance = m._conn.run_instances( image_id="ami-6a9e4503"
, instance_type=instance_type , instance_type=instance_type
, key_name=key_name , key_name=args.key_name
, placement=m.zone , placement=m.zone
, security_groups=["eelco-test"]).instances[0] , 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() 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 = m._conn.get_all_volumes([], filters={'attachment.instance-id': instance.id, 'attachment.device': "/dev/sda1"})[0]
old_root_volume.detach() old_root_volume.detach()
volume.detach() volume.detach()
charon.util.check_wait(lambda: volume.update() == 'available', max_tries=120) nixops.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: old_root_volume.update() == 'available', max_tries=120)
volume.attach(instance.id, '/dev/sda1') 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) ami_id = m._conn.create_image(instance.id, ami_name, description)
time.sleep(5) time.sleep(5)
image = m._conn.get_all_images([ami_id])[0] 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() instance.terminate()
else: else:
@ -123,7 +125,7 @@ else:
snapshot = volume.create_snapshot(description=description) snapshot = volume.create_snapshot(description=description)
print >> sys.stderr, "created snapshot {0}".format(snapshot.id) 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}) 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 = m._conn.get_all_images(image_ids=[ami_id])[0]
image.set_launch_permissions(user_ids=[], group_names=["all"]) image.set_launch_permissions(user_ids=[], group_names=["all"])
# Do a test deployment to make sure that the AMI works. # Do a test deployment to make sure that the AMI works.
f = open("ebs-test.nix", "w") f = open("ebs-test.nix", "w")
f.write( f.write(
@ -190,11 +191,30 @@ test_depl.name = "ebs-creator-test"
test_depl.nix_exprs = [os.path.abspath("./ebs-test.nix")] test_depl.nix_exprs = [os.path.abspath("./ebs-test.nix")]
test_depl.deploy(create_only=True) test_depl.deploy(create_only=True)
test_depl.machines['machine'].run_command("nixos-version") 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: if not args.keep:
test_depl.destroy_resources() test_depl.destroy_resources()
test_depl.delete() 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 #! /bin/sh -e
nixos=$(nix-instantiate --find-file nixos) 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) version=$(nix-instantiate --eval-only '<nixos>' -A config.system.nixosVersion | sed s/'"'//g)
echo "NixOS version is $version" echo "NixOS version is $version"

View File

@ -54,7 +54,7 @@ in
options = { options = {
environment.nix = mkOption { environment.nix = mkOption {
default = pkgs.nixUnstable; default = pkgs.nix;
merge = mergeOneOption; merge = mergeOneOption;
description = '' description = ''
This option specifies the Nix package instance to use throughout the system. This option specifies the Nix package instance to use throughout the system.
@ -220,7 +220,7 @@ in
}; };
binaryCaches = mkOption { binaryCaches = mkOption {
default = [ http://nixos.org/binary-cache ]; default = [ http://cache.nixos.org/ ];
type = types.listOf types.string; type = types.listOf types.string;
description = '' description = ''
List of binary cache URLs used to obtain pre-built binaries 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 in
{ {
@ -51,7 +53,10 @@ in
services.zabbixServer.dbServer = mkOption { services.zabbixServer.dbServer = mkOption {
default = "localhost"; 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 { services.zabbixServer.dbPassword = mkOption {
@ -65,7 +70,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.postgresql.enable = cfg.dbServer == "localhost"; services.postgresql.enable = useLocalPostgres;
users.extraUsers = singleton users.extraUsers = singleton
{ name = "zabbix"; { name = "zabbix";
@ -77,7 +82,7 @@ in
{ description = "Zabbix Server"; { description = "Zabbix Server";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = optional (cfg.dbServer == "localhost") "postgresql.service"; after = optional useLocalPostgres "postgresql.service";
preStart = preStart =
'' ''
@ -88,8 +93,8 @@ in
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true ${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
${pkgs.postgresql}/bin/createdb --owner zabbix 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/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/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" touch "${libDir}/db-created"
fi fi
''; '';
@ -100,6 +105,7 @@ in
serviceConfig.Type = "forking"; serviceConfig.Type = "forking";
serviceConfig.Restart = "always"; serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2; serviceConfig.RestartSec = 2;
serviceConfig.PIDFile = pidFile;
}; };
}; };

View File

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

View File

@ -93,7 +93,7 @@ with pkgs.lib;
[Service] [Service]
Environment=TERM=linux Environment=TERM=linux
Environment=LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive 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 Type=idle
Restart=always Restart=always
RestartSec=0 RestartSec=0

View File

@ -11,10 +11,11 @@ let
# we could generate zabbix.conf.php declaratively. # we could generate zabbix.conf.php declaratively.
zabbixPHP = pkgs.runCommand "${pkgs.zabbix.server.name}-php" {} 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 chmod -R u+w $out
#rm -rf $out/conf ln -s "${if config.configFile == null
ln -s ${config.stateDir}/zabbix.conf.php $out/conf/zabbix.conf.php then "${config.stateDir}/zabbix.conf.php"
else config.configFile}" "$out/conf/zabbix.conf.php"
''; '';
in in
@ -27,6 +28,7 @@ in
'' ''
post_max_size = 32M post_max_size = 32M
max_execution_time = 300 max_execution_time = 300
max_input_time = 300
''; '';
extraConfig = '' 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 { stateDir = pkgs.lib.mkOption {
default = "/var/lib/zabbix/frontend"; default = "/var/lib/zabbix/frontend";
description = " description = "

View File

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