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

View File

@ -68,6 +68,6 @@ fi
# Deploy the network # 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 ./result/bin/deploy-systems
rm -f result rm -f result

View File

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

View File

@ -1,8 +1,6 @@
{pkgs, options, config, ...}: {pkgs, options, config, ...}:
let let
to = throw "This is just a dummy keyword";
alias = from: to: { alias = from: to: {
name = "Alias"; name = "Alias";
@ -29,10 +27,16 @@ let
zipModules = list: with pkgs.lib; zipModules = list: with pkgs.lib;
zip (n: v: 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; ) list;
rename = statusTemplate: from: keyword: to: with pkgs.lib; rename = statusTemplate: from: to: with pkgs.lib;
let let
status = statusTemplate from to; status = statusTemplate from to;
setTo = setAttrByPath (splitString "." to); setTo = setAttrByPath (splitString "." to);
@ -60,30 +64,30 @@ let
in zipModules ([] in zipModules ([]
# usage example: # usage example:
# ++ rename alias "services.xserver.slim.theme" to "services.xserver.displayManager.slim.theme" # ++ rename alias "services.xserver.slim.theme" "services.xserver.displayManager.slim.theme"
++ rename obsolete "environment.extraPackages" to "environment.systemPackages" ++ rename obsolete "environment.extraPackages" "environment.systemPackages"
# Old Grub-related options. # Old Grub-related options.
++ rename obsolete "boot.copyKernels" to "boot.loader.grub.copyKernels" ++ rename obsolete "boot.copyKernels" "boot.loader.grub.copyKernels"
++ rename obsolete "boot.extraGrubEntries" to "boot.loader.grub.extraEntries" ++ rename obsolete "boot.extraGrubEntries" "boot.loader.grub.extraEntries"
++ rename obsolete "boot.extraGrubEntriesBeforeNixos" to "boot.loader.grub.extraEntriesBeforeNixOS" ++ rename obsolete "boot.extraGrubEntriesBeforeNixos" "boot.loader.grub.extraEntriesBeforeNixOS"
++ rename obsolete "boot.grubDevice" to "boot.loader.grub.device" ++ rename obsolete "boot.grubDevice" "boot.loader.grub.device"
++ rename obsolete "boot.bootMount" to "boot.loader.grub.bootDevice" ++ rename obsolete "boot.bootMount" "boot.loader.grub.bootDevice"
++ rename obsolete "boot.grubSplashImage" to "boot.loader.grub.splashImage" ++ 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 # OpenSSH
++ rename obsolete "services.sshd.ports" to "services.openssh.ports" ++ rename obsolete "services.sshd.ports" "services.openssh.ports"
++ rename obsolete "services.sshd.enable" to "services.openssh.enable" ++ rename obsolete "services.sshd.enable" "services.openssh.enable"
++ rename obsolete "services.sshd.allowSFTP" to "services.openssh.allowSFTP" ++ rename obsolete "services.sshd.allowSFTP" "services.openssh.allowSFTP"
++ rename obsolete "services.sshd.forwardX11" to "services.openssh.forwardX11" ++ rename obsolete "services.sshd.forwardX11" "services.openssh.forwardX11"
++ rename obsolete "services.sshd.gatewayPorts" to "services.openssh.gatewayPorts" ++ rename obsolete "services.sshd.gatewayPorts" "services.openssh.gatewayPorts"
++ rename obsolete "services.sshd.permitRootLogin" to "services.openssh.permitRootLogin" ++ rename obsolete "services.sshd.permitRootLogin" "services.openssh.permitRootLogin"
++ rename obsolete "services.xserver.startSSHAgent" to "services.xserver.startOpenSSHAgent" ++ rename obsolete "services.xserver.startSSHAgent" "services.xserver.startOpenSSHAgent"
# KDE # 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. ) # do not add renaming after this.

View File

@ -155,7 +155,11 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable { config = mkIf cfg.enable {
jobs = listToAttrs (mapAttrsFlatten (name: value: nameValuePair "openvpn-${name}" (makeOpenVPNJob value name)) cfg.servers); 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; 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: permitRootLoginCheck = v:
v == "yes" || v == "yes" ||
v == "without-password" || 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"; 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; 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 = []; default = [];
example = [ pkgs.kde4.kdesdk ]; example = [ pkgs.kde4.kdesdk ];
type = types.list types.package; 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 = { environment = {
kdePackages = [ systemPackages = [
pkgs.kde4.kdelibs pkgs.kde4.kdelibs
pkgs.kde4.kdebase pkgs.kde4.kdebase
pkgs.kde4.kdebase_runtime pkgs.kde4.kdebase_runtime
@ -69,9 +69,7 @@ in
pkgs.gst_all.gstPluginsGood pkgs.gst_all.gstPluginsGood
xorg.xmessage # so that startkde can show error messages xorg.xmessage # so that startkde can show error messages
xorg.xset # used by startkde, non-essential xorg.xset # used by startkde, non-essential
]; ] ++ config.environment.kdePackages;
x11Packages = config.environment.kdePackages;
pathsToLink = [ "/share" ]; pathsToLink = [ "/share" ];

View File

@ -33,7 +33,11 @@ in
# Set GTK_DATA_PREFIX so that GTK+ can find the Xfce themes. # Set GTK_DATA_PREFIX so that GTK+ can find the Xfce themes.
export GTK_DATA_PREFIX=${config.system.path} 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 exec ${pkgs.stdenv.shell} ${pkgs.xfce.xfceutils}/etc/xdg/xfce4/xinitrc
''; '';
}; };
@ -55,6 +59,7 @@ in
pkgs.xfce.xfce4panel pkgs.xfce.xfce4panel
pkgs.xfce.xfce4session pkgs.xfce.xfce4session
pkgs.xfce.xfce4settings pkgs.xfce.xfce4settings
pkgs.xfce.xfce4mixer
pkgs.xfce.xfceutils pkgs.xfce.xfceutils
pkgs.xfce.xfconf pkgs.xfce.xfconf
pkgs.xfce.xfdesktop pkgs.xfce.xfdesktop

View File

@ -100,7 +100,7 @@ in
services.xserver.displayManager.job = services.xserver.displayManager.job =
{ execCmd = { execCmd =
(optionalString (config.system.boot.loader.id == "grub") "PATH=${config.system.build.grub}/sbin:$PATH ") + (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; logsXsession = true;
}; };

View File

@ -72,7 +72,7 @@ in
boot.kernelModules = boot.kernelModules =
[ "xen_evtchn" "xen_gntdev" "xen_blkback" "xen_netback" "xen_pciback" [ "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 # The radeonfb kernel module causes the screen to go black as soon

View File

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

View File

@ -302,37 +302,31 @@ in {
{ inherit iso; { inherit iso;
nodes = { }; nodes = { };
testScript = testScript =
'' ''
# damn, it's costly to evaluate nixos-rebuild (1G of ram) # 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' }); my $machine = Machine->new({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1} -m 1024' });
$machine->start; $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");
# Make sure that we don't try to download anything. # Make sure that we don't try to download anything.
$machine->stopJob("dhclient"); $machine->stopJob("dhclient");
$machine->mustSucceed("rm /etc/resolv.conf"); $machine->mustSucceed("rm /etc/resolv.conf");
# Enable sshd service. # Enable sshd service.
$machine->mustSucceed( $machine->mustSucceed(
"sed -i 's,^}\$,jobs.sshd.startOn = pkgs.lib.mkOverride 0 \"startup\"; },' /etc/nixos/configuration.nix" "sed -i 's,^}\$,jobs.sshd.startOn = pkgs.lib.mkOverride 0 \"startup\"; },' /etc/nixos/configuration.nix"
); );
my $cfg = $machine->mustSucceed("cat /etc/nixos/configuration.nix"); my $cfg = $machine->mustSucceed("cat /etc/nixos/configuration.nix");
print STDERR "New CD config:\n$cfg\n"; print STDERR "New CD config:\n$cfg\n";
# Apply the new CD configuration. # Apply the new CD configuration.
$machine->mustSucceed("nixos-rebuild test --no-pull"); $machine->mustSucceed("nixos-rebuild test --no-pull");
# Connect to it-self. # Connect to it-self.
#$machine->waitForJob("sshd"); #$machine->waitForJob("sshd");
#$machine->mustSucceed("ssh root@127.0.0.1 echo hello"); #$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 ]; { require = [ ./common/x11.nix ];
services.xserver.driSupport = true; services.xserver.driSupport = true;
services.xserver.defaultDepth = pkgs.lib.mkOverrideTemplate 0 {} 16; services.xserver.defaultDepth = pkgs.lib.mkOverride 0 16;
environment.systemPackages = [ pkgs.icewm pkgs.quake3demo ]; environment.systemPackages = [ pkgs.quake3demo ];
}; };
nodes = nodes =