* More refactoring: renamed boot-environment.nix to system.nix (since
it does a lot more than just booting), and merged system-configuration.nix into system.nix. svn path=/nixos/trunk/; revision=7318
This commit is contained in:
parent
74783a4510
commit
2d0f190f20
@ -62,6 +62,37 @@
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["boot" "kernelParams"];
|
||||
default = [
|
||||
"selinux=0"
|
||||
"apm=on"
|
||||
"acpi=on"
|
||||
"vga=0x317"
|
||||
"console=tty1"
|
||||
"splash=verbose"
|
||||
];
|
||||
description = "
|
||||
The kernel parameters. If you want to add additional
|
||||
parameters, it's best to set
|
||||
<option>boot.extraKernelParams</options>.
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["boot" "extraKernelParams"];
|
||||
default = [
|
||||
];
|
||||
example = [
|
||||
"debugtrace"
|
||||
];
|
||||
description = "
|
||||
Additional user-defined kernel parameters.
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["networking" "useDHCP"];
|
||||
default = true;
|
||||
|
@ -1,63 +0,0 @@
|
||||
let
|
||||
|
||||
configuration = {
|
||||
boot = {
|
||||
autoDetectRootDevice = false;
|
||||
rootDevice = "/dev/hda1";
|
||||
readOnlyRoot = false;
|
||||
grubDevice = "/dev/hda";
|
||||
};
|
||||
};
|
||||
|
||||
# Build boot scripts.
|
||||
bootEnv = import ./boot-environment.nix {
|
||||
stage2Init = ""; # Passed on the command line via Grub.
|
||||
inherit configuration;
|
||||
};
|
||||
|
||||
# Extra kernel command line arguments.
|
||||
extraKernelParams = [
|
||||
"selinux=0"
|
||||
"apm=on"
|
||||
"acpi=on"
|
||||
"vga=0x317"
|
||||
"console=tty1"
|
||||
"splash=verbose"
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
with bootEnv;
|
||||
|
||||
rec {
|
||||
|
||||
inherit upstartJobs;
|
||||
|
||||
|
||||
system = pkgs.stdenvNew.mkDerivation {
|
||||
name = "system-configuration";
|
||||
builder = ./system-configuration.sh;
|
||||
switchToConfiguration = ./switch-to-configuration.sh;
|
||||
inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils;
|
||||
grubDevice = "/dev/hda"; # !!!
|
||||
inherit bootStage2;
|
||||
inherit activateConfiguration;
|
||||
inherit grubMenuBuilder;
|
||||
inherit etc;
|
||||
kernel = pkgs.kernel + "/vmlinuz";
|
||||
initrd = initialRamdisk + "/initrd";
|
||||
inherit extraKernelParams;
|
||||
# Most of these are needed by grub-install.
|
||||
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils];
|
||||
};
|
||||
|
||||
|
||||
grubMenuBuilder = pkgs.substituteAll {
|
||||
src = ../installer/grub-menu-builder.sh;
|
||||
isExecutable = true;
|
||||
inherit (pkgs) bash;
|
||||
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{ system ? __currentSystem
|
||||
, stage2Init
|
||||
{ platform ? __currentSystem
|
||||
, stage2Init ? ""
|
||||
, configuration
|
||||
}:
|
||||
|
||||
@ -10,15 +10,15 @@ rec {
|
||||
config = import ./config.nix pkgs.library configuration;
|
||||
|
||||
|
||||
pkgs = import ../pkgs/top-level/all-packages.nix {inherit system;};
|
||||
pkgs = import ../pkgs/top-level/all-packages.nix {system = platform;};
|
||||
|
||||
pkgsDiet = import ../pkgs/top-level/all-packages.nix {
|
||||
inherit system;
|
||||
system = platform;
|
||||
bootStdenv = pkgs.useDietLibC pkgs.stdenv;
|
||||
};
|
||||
|
||||
pkgsStatic = import ../pkgs/top-level/all-packages.nix {
|
||||
inherit system;
|
||||
system = platform;
|
||||
bootStdenv = pkgs.makeStaticBinaries pkgs.stdenv;
|
||||
};
|
||||
|
||||
@ -207,4 +207,40 @@ rec {
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
# Script to build the Grub menu containing the current and previous
|
||||
# system configurations.
|
||||
grubMenuBuilder = pkgs.substituteAll {
|
||||
src = ../installer/grub-menu-builder.sh;
|
||||
isExecutable = true;
|
||||
inherit (pkgs) bash;
|
||||
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
|
||||
};
|
||||
|
||||
|
||||
# Putting it all together. This builds a store object containing
|
||||
# symlinks to the various parts of the built configuration (the
|
||||
# kernel, the Upstart services, the init scripts, etc.) as well as a
|
||||
# script `switch-to-configuration' that activates the configuration
|
||||
# and makes it bootable.
|
||||
system = pkgs.stdenvNew.mkDerivation {
|
||||
name = "system";
|
||||
builder = ./system.sh;
|
||||
switchToConfiguration = ./switch-to-configuration.sh;
|
||||
inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils;
|
||||
grubDevice = config.get ["boot" "grubDevice"];
|
||||
kernelParams =
|
||||
(config.get ["boot" "kernelParams"]) ++
|
||||
(config.get ["boot" "extraKernelParams"]);
|
||||
inherit bootStage2;
|
||||
inherit activateConfiguration;
|
||||
inherit grubMenuBuilder;
|
||||
inherit etc;
|
||||
kernel = pkgs.kernel + "/vmlinuz";
|
||||
initrd = initialRamdisk + "/initrd";
|
||||
# Most of these are needed by grub-install.
|
||||
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils];
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -9,10 +9,10 @@ ln -s $initrd $out/initrd
|
||||
ln -s $activateConfiguration $out/activate
|
||||
ln -s $etc/etc $out/etc
|
||||
|
||||
echo "$extraKernelParams" > $out/kernel-params
|
||||
echo "$kernelParams" > $out/kernel-params
|
||||
|
||||
cat > $out/menu.lst << GRUBEND
|
||||
kernel $kernel init=$bootStage2 $extraKernelParams
|
||||
kernel $kernel init=$bootStage2 $kernelParams
|
||||
initrd $initrd
|
||||
GRUBEND
|
||||
|
@ -23,6 +23,10 @@ addEntry() {
|
||||
name="$1"
|
||||
path="$2"
|
||||
|
||||
if ! test -e $path/menu.lst; then
|
||||
return
|
||||
fi
|
||||
|
||||
cat >> $tmp << GRUBEND
|
||||
title $name
|
||||
GRUBEND
|
||||
|
8
instances/examples/basic.nix
Normal file
8
instances/examples/basic.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
boot = {
|
||||
autoDetectRootDevice = false;
|
||||
rootDevice = "/dev/hda1";
|
||||
readOnlyRoot = false;
|
||||
grubDevice = "/dev/hda";
|
||||
};
|
||||
}
|
4
test.sh
4
test.sh
@ -1,4 +1,6 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
nix-build configuration/system-configuration.nix -A system -K -k
|
||||
nix-build configuration/system.nix \
|
||||
--arg configuration 'import ./instances/example.nix' \
|
||||
-A system -K -k
|
||||
./result/bin/switch-to-configuration test
|
||||
|
@ -1,4 +1,6 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
nix-env -p /nix/var/nix/profiles/system -f configuration/system-configuration.nix -i -A systemConfiguration
|
||||
nix-env -p /nix/var/nix/profiles/system -f configuration/system.nix \
|
||||
--arg configuration 'import ./instances/example.nix' \
|
||||
-i -A system
|
||||
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
||||
|
Loading…
Reference in New Issue
Block a user