forked from mirrors/nixpkgs
* Added a module to enable the Xen hypervisor.
svn path=/nixos/trunk/; revision=23739
This commit is contained in:
parent
9f06fb806c
commit
987dd76811
|
@ -190,16 +190,16 @@ EOF
|
|||
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 @@ GRUBEND
|
|||
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
|
||||
|
|
|
@ -154,4 +154,5 @@
|
|||
./tasks/network-interfaces.nix
|
||||
./tasks/swraid.nix
|
||||
./tasks/tty-backgrounds.nix
|
||||
./virtualisation/xen.nix
|
||||
]
|
||||
|
|
|
@ -43,30 +43,19 @@ let
|
|||
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 @@ let
|
|||
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 @@ in {
|
|||
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;
|
||||
}
|
||||
|
|
76
modules/virtualisation/xen.nix
Normal file
76
modules/virtualisation/xen.nix
Normal file
|
@ -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
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue