Updating from trunk. Blind commit - no coflicts.

svn path=/nixos/branches/stdenv-updates/; revision=24370
This commit is contained in:
Lluís Batlle i Rossell 2010-10-19 20:45:35 +00:00
commit 1acbc4a82f
15 changed files with 209 additions and 99 deletions

View File

@ -330,6 +330,12 @@ sub waitForFile {
}
}
sub startJob {
my ($self, $jobName) = @_;
$self->execute("initctl start $jobName");
my ($status, $out) = $self->execute("initctl status $jobName");
die "failed to start $jobName" unless $out =~ /start\/running/;
}
sub stopJob {
my ($self, $jobName) = @_;

View File

@ -0,0 +1,34 @@
{pkgs, config, ...}:
{
###### interface
options = {
networking.enableIntel2100BGFirmware = pkgs.lib.mkOption {
default = false;
type = pkgs.lib.types.bool;
description = ''
Turn on this option if you want firmware for the Intel
PRO/Wireless 2100BG to be loaded automatically. This is
required if you want to use this device. Intel requires you to
accept the license for this firmware, see
<link xlink:href='http://ipw2100.sourceforge.net/firmware.php?fid=2'/>.
'';
};
};
###### implementation
config = pkgs.lib.mkIf config.networking.enableIntel2100BGFirmware {
# Warning: setting this option requires acceptance of the firmware
# license, see http://ipw2100.sourceforge.net/firmware.php?fid=2.
hardware.firmware = [ pkgs.ipw2100fw ];
};
}

View File

@ -2,33 +2,71 @@
, nixpkgs ? /etc/nixos/nixpkgs
, networkExpr
, infrastructureExpr
, targetProperty ? "hostname"
}:
let
pkgs = import nixpkgs {};
inherit (builtins) attrNames getAttr listToAttrs concatMapStrings;
inherit (builtins) attrNames getAttr listToAttrs;
inherit (pkgs.lib) concatMapStrings;
network = import networkExpr;
infrastructure = import infrastructureExpr;
generateScript = network: infrastructure: configs:
generateRollbackSucceededPhase = network: infrastructure: configs:
concatMapStrings (configurationName:
let
infrastructureElement = getAttr configurationName infrastructure;
config = getAttr configurationName configs;
in
''
echo "=== upgrading ${infrastructureElement.hostName} ==="
nix-copy-closure --to ${infrastructureElement.hostName} ${config.system.build.toplevel} \
&& ssh $NIX_SSHOPTS ${infrastructureElement.hostName} nix-env -p /nix/var/nix/profiles/system --set ${config.system.build.toplevel} \
&& ssh $NIX_SSHOPTS ${infrastructureElement.hostName} ${config.system.build.toplevel}/bin/switch-to-configuration switch \
&& { succeeded=$((succeeded + 1)); } \
|| { failed=$((failed + 1)); echo 'WARNING: upgrade of ${infrastructureElement.hostName} failed!'; }
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/bin/switch-to-configuration switch
rollback=$((rollback + 1))
fi
''
) (attrNames network)
;
generateDistributionPhase = network: infrastructure: 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}
''
) (attrNames network)
;
generateActivationPhase = network: infrastructure: 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)
ssh $NIX_SSHOPTS ${getAttr targetProperty infrastructureElement} /nix/var/nix/profiles/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/bin/switch-to-configuration switch
rollbackSucceeded
)
succeeded=$((succeeded + 1))
''
) (attrNames network)
;
evaluateMachines = network: infrastructure:
listToAttrs (map (configurationName:
let
@ -48,13 +86,27 @@ let
in
pkgs.stdenv.mkDerivation {
name = "deploy-script";
buildCommand = ''
buildCommand =
''
ensureDir $out/bin
cat > $out/bin/deploy-systems << "EOF"
#! ${pkgs.stdenv.shell} -e
failed=0; succeeded=0
${generateScript network infrastructure configs}
echo "Upgrade of $failed machines failed, $succeeded machines succeeded.";
rollbackSucceeded()
{
rollback=0
${generateRollbackSucceededPhase network infrastructure configs}
}
# Distribution phase
${generateDistributionPhase network infrastructure configs}
# Activation phase
succeeded=0
${generateActivationPhase network infrastructure configs}
EOF
chmod +x $out/bin/deploy-systems
'';

View File

@ -68,6 +68,6 @@ fi
# Deploy the network
nix-build $NIXOS/deploy.nix --argstr networkExpr $networkExpr --argstr infrastructureExpr $infrastructureExpr $showTraceArg
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

View File

@ -12,6 +12,7 @@
./config/timezone.nix
./config/unix-odbc-drivers.nix
./config/users-groups.nix
./hardware/network/intel-2100bg.nix
./hardware/network/intel-2200bg.nix
./hardware/network/intel-3945abg.nix
./hardware/network/rt73.nix

View File

@ -1,8 +1,6 @@
{pkgs, options, config, ...}:
let
to = throw "This is just a dummy keyword";
alias = from: to: {
name = "Alias";
@ -29,10 +27,16 @@ let
zipModules = list: with pkgs.lib;
zip (n: v:
if tail v != [] then zipModules v else head v
if tail v != [] then
if n == "_type" then builtins.trace "Merge _type" (head v)
else if n == "extraConfigs" then builtins.trace "Merge extraConfigs" (concatLists v)
else if n == "description" || n == "apply" then
abort "Cannot rename an option to multiple options."
else zipModules v
else head v
) list;
rename = statusTemplate: from: keyword: to: with pkgs.lib;
rename = statusTemplate: from: to: with pkgs.lib;
let
status = statusTemplate from to;
setTo = setAttrByPath (splitString "." to);
@ -60,30 +64,30 @@ let
in zipModules ([]
# usage example:
# ++ rename alias "services.xserver.slim.theme" to "services.xserver.displayManager.slim.theme"
++ rename obsolete "environment.extraPackages" to "environment.systemPackages"
# ++ rename alias "services.xserver.slim.theme" "services.xserver.displayManager.slim.theme"
++ rename obsolete "environment.extraPackages" "environment.systemPackages"
# Old Grub-related options.
++ rename obsolete "boot.copyKernels" to "boot.loader.grub.copyKernels"
++ rename obsolete "boot.extraGrubEntries" to "boot.loader.grub.extraEntries"
++ rename obsolete "boot.extraGrubEntriesBeforeNixos" to "boot.loader.grub.extraEntriesBeforeNixOS"
++ rename obsolete "boot.grubDevice" to "boot.loader.grub.device"
++ rename obsolete "boot.bootMount" to "boot.loader.grub.bootDevice"
++ rename obsolete "boot.grubSplashImage" to "boot.loader.grub.splashImage"
++ rename obsolete "boot.copyKernels" "boot.loader.grub.copyKernels"
++ rename obsolete "boot.extraGrubEntries" "boot.loader.grub.extraEntries"
++ rename obsolete "boot.extraGrubEntriesBeforeNixos" "boot.loader.grub.extraEntriesBeforeNixOS"
++ rename obsolete "boot.grubDevice" "boot.loader.grub.device"
++ rename obsolete "boot.bootMount" "boot.loader.grub.bootDevice"
++ rename obsolete "boot.grubSplashImage" "boot.loader.grub.splashImage"
++ rename obsolete "boot.initrd.extraKernelModules" to "boot.initrd.kernelModules"
++ rename obsolete "boot.initrd.extraKernelModules" "boot.initrd.kernelModules"
# OpenSSH
++ rename obsolete "services.sshd.ports" to "services.openssh.ports"
++ rename obsolete "services.sshd.enable" to "services.openssh.enable"
++ rename obsolete "services.sshd.allowSFTP" to "services.openssh.allowSFTP"
++ rename obsolete "services.sshd.forwardX11" to "services.openssh.forwardX11"
++ rename obsolete "services.sshd.gatewayPorts" to "services.openssh.gatewayPorts"
++ rename obsolete "services.sshd.permitRootLogin" to "services.openssh.permitRootLogin"
++ rename obsolete "services.xserver.startSSHAgent" to "services.xserver.startOpenSSHAgent"
++ rename obsolete "services.sshd.ports" "services.openssh.ports"
++ rename obsolete "services.sshd.enable" "services.openssh.enable"
++ rename obsolete "services.sshd.allowSFTP" "services.openssh.allowSFTP"
++ rename obsolete "services.sshd.forwardX11" "services.openssh.forwardX11"
++ rename obsolete "services.sshd.gatewayPorts" "services.openssh.gatewayPorts"
++ rename obsolete "services.sshd.permitRootLogin" "services.openssh.permitRootLogin"
++ rename obsolete "services.xserver.startSSHAgent" "services.xserver.startOpenSSHAgent"
# KDE
++ rename deprecated "kde.extraPackages" to "environment.kdePackages"
++ rename deprecated "kde.extraPackages" "environment.kdePackages"
# ++ rename obsolete "environment.kdePackages" "environment.systemPackages" # !!! doesn't work!
) # do not add renaming after this.

View File

@ -155,7 +155,11 @@ in
###### implementation
config = mkIf cfg.enable {
jobs = listToAttrs (mapAttrsFlatten (name: value: nameValuePair "openvpn-${name}" (makeOpenVPNJob value name)) cfg.servers);
environment.systemPackages = [ openvpn ];
};
}

View File

@ -8,31 +8,6 @@ let
nssModulesPath = config.system.nssModules.path;
sshdConfig = pkgs.writeText "sshd_config"
''
Protocol 2
UsePAM yes
${ concatMapStrings (port : ''Port ${toString port}
'') cfg.ports}
${if cfg.forwardX11 then "
X11Forwarding yes
XAuthLocation ${pkgs.xlibs.xauth}/bin/xauth
" else "
X11Forwarding no
"}
${if cfg.allowSFTP then "
Subsystem sftp ${pkgs.openssh}/libexec/sftp-server
" else "
"}
PermitRootLogin ${cfg.permitRootLogin}
GatewayPorts ${cfg.gatewayPorts}
'';
permitRootLoginCheck = v:
v == "yes" ||
v == "without-password" ||
@ -102,6 +77,11 @@ in
'';
};
extraConfig = mkOption {
default = "";
description = "Verbatim contents of <filename>sshd_config</filename>.";
};
};
};
@ -146,10 +126,40 @@ in
daemonType = "fork";
exec = "${pkgs.openssh}/sbin/sshd -h /etc/ssh/ssh_host_dsa_key -f ${sshdConfig}";
exec =
''
${pkgs.openssh}/sbin/sshd -h /etc/ssh/ssh_host_dsa_key \
-f ${pkgs.writeText "sshd_config" cfg.extraConfig}
'';
};
networking.firewall.allowedTCPPorts = cfg.ports;
services.openssh.extraConfig =
''
Protocol 2
UsePAM yes
${concatMapStrings (port: ''
Port ${toString port}
'') cfg.ports}
${if cfg.forwardX11 then ''
X11Forwarding yes
XAuthLocation ${pkgs.xlibs.xauth}/bin/xauth
'' else ''
X11Forwarding no
''}
${optionalString cfg.allowSFTP ''
Subsystem sftp ${pkgs.openssh}/libexec/sftp-server
''}
PermitRootLogin ${cfg.permitRootLogin}
GatewayPorts ${cfg.gatewayPorts}
'';
};
}

View File

@ -23,7 +23,7 @@ in
default = [];
example = [ pkgs.kde4.kdesdk ];
type = types.list types.package;
description = "Additional KDE 4 programs. Only a minimal set is installed by default.";
description = "This option is obsolete. Please use <option>environment.systemPackages</option> instead.";
};
};
@ -56,7 +56,7 @@ in
} ];
environment = {
kdePackages = [
systemPackages = [
pkgs.kde4.kdelibs
pkgs.kde4.kdebase
pkgs.kde4.kdebase_runtime
@ -69,9 +69,7 @@ in
pkgs.gst_all.gstPluginsGood
xorg.xmessage # so that startkde can show error messages
xorg.xset # used by startkde, non-essential
];
x11Packages = config.environment.kdePackages;
] ++ config.environment.kdePackages;
pathsToLink = [ "/share" ];

View File

@ -33,7 +33,11 @@ in
# Set GTK_DATA_PREFIX so that GTK+ can find the Xfce themes.
export GTK_DATA_PREFIX=${config.system.path}
# Necessary to get xfce4-mixer to find GST's ALSA plugin.
# Ugly.
export GST_PLUGIN_PATH=${config.system.path}/lib
exec ${pkgs.stdenv.shell} ${pkgs.xfce.xfceutils}/etc/xdg/xfce4/xinitrc
'';
};
@ -55,6 +59,7 @@ in
pkgs.xfce.xfce4panel
pkgs.xfce.xfce4session
pkgs.xfce.xfce4settings
pkgs.xfce.xfce4mixer
pkgs.xfce.xfceutils
pkgs.xfce.xfconf
pkgs.xfce.xfdesktop

View File

@ -100,7 +100,7 @@ in
services.xserver.displayManager.job =
{ execCmd =
(optionalString (config.system.boot.loader.id == "grub") "PATH=${config.system.build.grub}/sbin:$PATH ") +
"exec ${kdebase_workspace}/bin/kdm -config ${kdmrc} -nodaemon";
"KDEDIRS=${kdebase_workspace} exec ${kdebase_workspace}/bin/kdm -config ${kdmrc} -nodaemon";
logsXsession = true;
};

View File

@ -72,7 +72,7 @@ in
boot.kernelModules =
[ "xen_evtchn" "xen_gntdev" "xen_blkback" "xen_netback" "xen_pciback"
"blktap" "tap"
"blktap" "tun"
];
# The radeonfb kernel module causes the screen to go black as soon

View File

@ -159,12 +159,14 @@ let
system = "i686-linux";
};
in {
avahi = t.avahi.test;
bittorrent = t.bittorrent.test;
firefox = t.firefox.test;
installer.lvm = t.installer.lvm.test;
installer.separateBoot = t.installer.separateBoot.test;
installer.simple = t.installer.simple.test;
installer.swraid = t.installer.swraid.test;
installer.rebuildCD = t.installer.rebuildCD.test;
kde4 = t.kde4.test;
login = t.login.test;
nat = t.nat.test;

View File

@ -302,37 +302,31 @@ in {
{ inherit iso;
nodes = { };
testScript =
''
# damn, it's costly to evaluate nixos-rebuild (1G of ram)
my $machine = Machine->new({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1} -m 1024' });
$machine->start;
# Make sure that we get a login prompt etc.
$machine->mustSucceed("echo hello");
$machine->waitForJob("tty1");
$machine->waitForJob("rogue");
$machine->waitForJob("nixos-manual");
''
# damn, it's costly to evaluate nixos-rebuild (1G of ram)
my $machine = Machine->new({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1} -m 1024' });
$machine->start;
# Make sure that we don't try to download anything.
$machine->stopJob("dhclient");
$machine->mustSucceed("rm /etc/resolv.conf");
# Make sure that we don't try to download anything.
$machine->stopJob("dhclient");
$machine->mustSucceed("rm /etc/resolv.conf");
# Enable sshd service.
$machine->mustSucceed(
"sed -i 's,^}\$,jobs.sshd.startOn = pkgs.lib.mkOverride 0 \"startup\"; },' /etc/nixos/configuration.nix"
);
# Enable sshd service.
$machine->mustSucceed(
"sed -i 's,^}\$,jobs.sshd.startOn = pkgs.lib.mkOverride 0 \"startup\"; },' /etc/nixos/configuration.nix"
);
my $cfg = $machine->mustSucceed("cat /etc/nixos/configuration.nix");
print STDERR "New CD config:\n$cfg\n";
my $cfg = $machine->mustSucceed("cat /etc/nixos/configuration.nix");
print STDERR "New CD config:\n$cfg\n";
# Apply the new CD configuration.
$machine->mustSucceed("nixos-rebuild test --no-pull");
# Apply the new CD configuration.
$machine->mustSucceed("nixos-rebuild test --no-pull");
# Connect to it-self.
#$machine->waitForJob("sshd");
#$machine->mustSucceed("ssh root@127.0.0.1 echo hello");
# Connect to it-self.
#$machine->waitForJob("sshd");
#$machine->mustSucceed("ssh root@127.0.0.1 echo hello");
$machine->shutdown;
'';
$machine->shutdown;
'';
};
}

View File

@ -7,8 +7,8 @@ rec {
{ require = [ ./common/x11.nix ];
services.xserver.driSupport = true;
services.xserver.defaultDepth = pkgs.lib.mkOverrideTemplate 0 {} 16;
environment.systemPackages = [ pkgs.icewm pkgs.quake3demo ];
services.xserver.defaultDepth = pkgs.lib.mkOverride 0 16;
environment.systemPackages = [ pkgs.quake3demo ];
};
nodes =