diff --git a/modules/installer/grub/grub-menu-builder.sh b/modules/installer/grub/grub-menu-builder.sh index 4caafe9da63b..8934c9bd24de 100644 --- a/modules/installer/grub/grub-menu-builder.sh +++ b/modules/installer/grub/grub-menu-builder.sh @@ -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 diff --git a/modules/module-list.nix b/modules/module-list.nix index 5a1efdabf411..973c3a3e4939 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -154,4 +154,5 @@ ./tasks/network-interfaces.nix ./tasks/swraid.nix ./tasks/tty-backgrounds.nix + ./virtualisation/xen.nix ] diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index cb3c4e8941dc..f2bbbc5ffb0d 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -43,30 +43,19 @@ let system.copySystemConfiguration = pkgs.lib.mkOption { default = false; description = '' - Unless set to false copies the nixos configuration file - $NIXOS_CONFIG defaulting to - /etc/nixos/configuration.nix + If enabled, copies the NixOS configuration file + $NIXOS_CONFIG (usually + /etc/nixos/configuration.nix) to the system store path. - See - 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: - - cp ${pkgs.lib.maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"} $out - - 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; } diff --git a/modules/virtualisation/xen.nix b/modules/virtualisation/xen.nix new file mode 100644 index 000000000000..5e8bb902b2a7 --- /dev/null +++ b/modules/virtualisation/xen.nix @@ -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 domains, to run + concurrently on the physical machine. NixOS runs as the + privileged Domain 0. 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 + ''; + + }; + +}