Author: eelco
Date: Sun Sep 12 22:43:45 2010
New Revision: 23739
URL: https://svn.nixos.org/websvn/nix/?rev=23739&sc=1
Log:
* Added a module to enable the Xen hypervisor.
Added:
nixos/trunk/modules/virtualisation/xen.nix
Modified:
nixos/trunk/modules/installer/grub/grub-menu-builder.sh
nixos/trunk/modules/module-list.nix
nixos/trunk/modules/system/activation/top-level.nix
Modified: nixos/trunk/modules/installer/grub/grub-menu-builder.sh
==============================================================================
--- nixos/trunk/modules/installer/grub/grub-menu-builder.sh Sat Sep 11
20:32:23 2010 (r23738)
+++ nixos/trunk/modules/installer/grub/grub-menu-builder.sh Sun Sep 12
22:43:45 2010 (r23739)
@@ -190,16 +190,16 @@
name="$confName $3"
fi
- local kernelArgs="systemConfig=$(readlink -f $path) init=$(readlink -f
$path/init) $(cat $path/kernel-params)"
- local xenArgs="loglvl=all guest_loglvl=all"
+ local kernelParams="systemConfig=$(readlink -f $path) init=$(readlink -f
$path/init) $(cat $path/kernel-params)"
+ local xenParams="$([ -n "$xen" ] && cat $path/xen-params)"
case "$grubVersion" in
1)
cat >> "$tmp" << GRUBEND
title $name
@extraPerEntryConfig@
- ${xen:+kernel $xen $xenArgs}
- $(if [ -z "$xen" ]; then echo kernel; else echo module; fi) $kernel
$kernelArgs
+ ${xen:+kernel $xen $xenParams}
+ $(if [ -z "$xen" ]; then echo kernel; else echo module; fi) $kernel
$kernelParams
module $initrd
GRUBEND
;;
@@ -207,8 +207,8 @@
cat >> "$tmp" << GRUBEND
menuentry "$name" {
@extraPerEntryConfig@
- ${xen:+multiboot $xen $xenArgs}
- $(if [ -z "$xen" ]; then echo linux; else echo module; fi) $kernel
$kernelArgs
+ ${xen:+multiboot $xen $xenParams}
+ $(if [ -z "$xen" ]; then echo linux; else echo module; fi) $kernel
$kernelParams
$(if [ -z "$xen" ]; then echo initrd; else echo module; fi) $initrd
}
GRUBEND
Modified: nixos/trunk/modules/module-list.nix
==============================================================================
--- nixos/trunk/modules/module-list.nix Sat Sep 11 20:32:23 2010 (r23738)
+++ nixos/trunk/modules/module-list.nix Sun Sep 12 22:43:45 2010 (r23739)
@@ -154,4 +154,5 @@
./tasks/network-interfaces.nix
./tasks/swraid.nix
./tasks/tty-backgrounds.nix
+ ./virtualisation/xen.nix
]
Modified: nixos/trunk/modules/system/activation/top-level.nix
==============================================================================
--- nixos/trunk/modules/system/activation/top-level.nix Sat Sep 11 20:32:23
2010 (r23738)
+++ nixos/trunk/modules/system/activation/top-level.nix Sun Sep 12 22:43:45
2010 (r23739)
@@ -43,30 +43,19 @@
system.copySystemConfiguration = pkgs.lib.mkOption {
default = false;
description = ''
- Unless set to false copies the nixos configuration file
- <literal>$NIXOS_CONFIG</literal> defaulting to
- <filename>/etc/nixos/configuration.nix</filename>
+ If enabled, copies the NixOS configuration file
+ <literal>$NIXOS_CONFIG</literal> (usually
+ <filename>/etc/nixos/configuration.nix</filename>)
to the system store path.
- See <option>extraSystemBuilderCmds</option>
- if you want to do add more customized info
- to your system storepath.
'';
};
system.extraSystemBuilderCmds = pkgs.lib.mkOption {
default = "";
+ internal = true;
merge = pkgs.lib.concatStringsSep "\n";
description = ''
This code will be added to the builder creating the system store path.
- This use case copies your configuration file into the system
derivation:
- <command>
- cp ${pkgs.lib.maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"}
$out
- </command>
- Of course you could add code saving a svn diff or svn revision number
- of both nixos and nixpkgs repositories as well. Keep in mind that when
- you build in chroots that you have do either copy sources to store or
- add them to the chroot somehow.
- You still should consider putting your configuration into a VCS.
'';
};
@@ -107,6 +96,7 @@
echo "(Expecting ${kernelPath})"
false
fi
+
ln -s ${kernelPath} $out/kernel
ln -s ${config.system.modulesTree} $out/kernel-modules
if [ -n "$grub" ]; then
@@ -181,8 +171,9 @@
require = [options];
system.extraSystemBuilderCmds =
- pkgs.lib.optionalString
- config.system.copySystemConfiguration
- "cp ${pkgs.lib.maybeEnv "NIXOS_CONFIG"
"/etc/nixos/configuration.nix"} $out";
+ pkgs.lib.optionalString
+ config.system.copySystemConfiguration
+ "cp ${pkgs.lib.maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"}
$out";
+
system.build.toplevel = system;
}
Added: nixos/trunk/modules/virtualisation/xen.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nixos/trunk/modules/virtualisation/xen.nix Sun Sep 12 22:43:45 2010
(r23739)
@@ -0,0 +1,76 @@
+# Xen hypervisor support.
+
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let cfg = config.virtualisation.xen; in
+
+{
+ ###### interface
+
+ options = {
+
+ virtualisation.xen.enable =
+ mkOption {
+ default = false;
+ description =
+ ''
+ Setting this option enables the Xen hypervisor, a
+ virtualisation technology that allows multiple virtual
+ machines, known as <emphasis>domains</emphasis>, to run
+ concurrently on the physical machine. NixOS runs as the
+ privileged <emphasis>Domain 0</emphasis>. This option
+ requires a reboot to take effect.
+ '';
+ };
+
+ virtualisation.xen.bootParams =
+ mkOption {
+ default = "";
+ description =
+ ''
+ Parameters passed to the Xen hypervisor at boot time.
+ '';
+ };
+
+ virtualisation.xen.domain0MemorySize =
+ mkOption {
+ default = 0;
+ example = 512;
+ description =
+ ''
+ Amount of memory (in MiB) allocated to Domain 0 on boot.
+ If set to 0, all memory is assigned to Domain 0.
+ '';
+ };
+
+ };
+
+
+ ###### implementation
+
+ config = mkIf cfg.enable {
+
+ environment.systemPackages = [ pkgs.xen ];
+
+ # Domain 0 requires a pvops-enabled kernel.
+ boot.kernelPackages = pkgs.linuxPackages_2_6_32_xen;
+
+ # The radeonfb kernel module causes the screen to go black as soon
+ # as it's loaded, so don't load it.
+ boot.blacklistedKernelModules = [ "radeonfb" ];
+
+ virtualisation.xen.bootParams =
+ [ "loglvl=all" "guest_loglvl=all" ] ++
+ optional (cfg.domain0MemorySize != 0) "dom0_mem=${toString
cfg.domain0MemorySize}M";
+
+ system.extraSystemBuilderCmds =
+ ''
+ ln -s ${pkgs.xen}/boot/xen.gz $out/xen.gz
+ echo "${toString cfg.bootParams}" > $out/xen-params
+ '';
+
+ };
+
+}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits