diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix
index f8b84eb6fdb..63c562a13b9 100644
--- a/boot/boot-stage-1.nix
+++ b/boot/boot-stage-1.nix
@@ -21,14 +21,13 @@
stage2Init ? "/init"
}:
-assert !autoDetectRootDevice -> rootDevice != "";
-assert autoDetectRootDevice -> rootLabel != "";
-
substituteAll {
src = ./boot-stage-1-init.sh;
isExecutable = true;
inherit staticShell modules;
- inherit autoDetectRootDevice rootDevice rootLabel;
+ inherit autoDetectRootDevice;
+ rootDevice = if !autoDetectRootDevice then rootDevice else "";
+ rootLabel = if autoDetectRootDevice then rootLabel else "";
path = [
staticTools
module_init_tools
diff --git a/configuration/boot-environment.nix b/configuration/boot-environment.nix
index 31af084695c..762e2042401 100644
--- a/configuration/boot-environment.nix
+++ b/configuration/boot-environment.nix
@@ -1,17 +1,13 @@
{ system ? __currentSystem
-, autoDetectRootDevice ? false
-, rootDevice ? ""
-, rootLabel ? ""
, stage2Init
-, readOnlyRoot
-, configData ? {}
+, configuration
}:
rec {
# Make a configuration object from which we can retrieve option
# values.
- config = import ./config.nix pkgs.library configData;
+ config = import ./config.nix pkgs.library configuration;
pkgs = import ../pkgs/top-level/all-packages.nix {inherit system;};
@@ -71,7 +67,9 @@ rec {
inherit (pkgs) substituteAll;
inherit (pkgsDiet) module_init_tools;
inherit extraUtils;
- inherit autoDetectRootDevice rootDevice rootLabel;
+ autoDetectRootDevice = config.get ["boot" "autoDetectRootDevice"];
+ rootDevice = config.get ["boot" "rootDevice"];
+ rootLabel = config.get ["boot" "rootLabel"];
inherit stage2Init;
modules = modulesClosure;
staticShell = stdenvLinuxStuff.bootstrapTools.bash;
@@ -172,8 +170,8 @@ rec {
isExecutable = true;
inherit etc;
- inherit readOnlyRoot;
inherit (pkgs) kernel;
+ readOnlyRoot = config.get ["boot" "readOnlyRoot"];
hostName = config.get ["networking" "hostname"];
wrapperDir = setuidWrapper.wrapperDir;
accounts = ../helpers/accounts.sh;
@@ -198,8 +196,8 @@ rec {
bootStage2 = import ../boot/boot-stage-2.nix {
inherit (pkgs) substituteAll coreutils
utillinux kernel udev upstart;
- inherit readOnlyRoot;
inherit activateConfiguration;
+ readOnlyRoot = config.get ["boot" "readOnlyRoot"];
upstartPath = [
pkgs.coreutils
pkgs.findutils
diff --git a/configuration/options.nix b/configuration/options.nix
index 4cd2f3a7343..31842627bb5 100644
--- a/configuration/options.nix
+++ b/configuration/options.nix
@@ -1,11 +1,67 @@
-[
+[
- {
+
+ {
name = ["networking" "hostname"];
default = "nixos";
description = "The name of the machine.";
}
+
+ {
+ name = ["boot" "autoDetectRootDevice"];
+ default = false;
+ description = "
+ Whether to find the root device automatically by searching for a
+ device with the right label. If this option is off, then
+ must be set.
+ ";
+ }
+
+
+ {
+ name = ["boot" "rootDevice"];
+ example = "/dev/hda1";
+ description = "
+ The device to be mounted on / at system startup.
+ ";
+ }
+
+
+ {
+ name = ["boot" "readOnlyRoot"];
+ default = false;
+ description = "
+ Whether the root device should be mounted writable. This should
+ be set when booting from CD-ROM.
+ ";
+ }
+
+
+ {
+ name = ["boot" "rootLabel"];
+ description = "
+ When auto-detecting the root device (see
+ ), this option
+ specifies the label of the root device. Right now, this is
+ merely a file name that should exist in the root directory of
+ the file system. It is used to find the boot CD-ROM.
+ ";
+ }
+
+
+ {
+ name = ["boot" "grubDevice"];
+ default = "";
+ example = "/dev/hda";
+ description = "
+ The device on which the boot loader, Grub, will be installed.
+ If empty, Grub won't be installed and it's your responsibility
+ to make the system bootable.
+ ";
+ }
+
+
{
name = ["networking" "useDHCP"];
default = true;
@@ -16,6 +72,7 @@
";
}
+
{
name = ["networking" "interfaces"];
default = [];
@@ -33,6 +90,7 @@
";
}
+
{
name = ["filesystems" "mountPoints"];
example = [
@@ -48,6 +106,7 @@
";
}
+
{
name = ["services" "syslogd" "tty"];
default = 10;
@@ -56,7 +115,8 @@
messages.
";
}
-
+
+
{
name = ["services" "mingetty" "ttys"];
default = [1 2 3 4 5 6];
@@ -65,7 +125,8 @@
login prompt.
";
}
-
+
+
{
name = ["services" "mingetty" "waitOnMounts"];
default = false;
@@ -77,6 +138,7 @@
";
}
+
{
name = ["services" "sshd" "enable"];
default = false;
@@ -86,6 +148,7 @@
";
}
+
{
name = ["services" "sshd" "forwardX11"];
default = false;
@@ -94,4 +157,5 @@
";
}
+
]
diff --git a/configuration/system-configuration.nix b/configuration/system-configuration.nix
index 39b4f961f16..6e6b6bc6e0f 100644
--- a/configuration/system-configuration.nix
+++ b/configuration/system-configuration.nix
@@ -1,18 +1,18 @@
let
- # The root device.
- rootDevice = "/dev/hda1";
-
- # The device on which GRUB should be installed (leave empty if you
- # don't want GRUB to be installed).
- grubDevice = "/dev/hda";
+ configuration = {
+ boot = {
+ autoDetectRootDevice = false;
+ rootDevice = "/dev/hda1";
+ readOnlyRoot = false;
+ grubDevice = "/dev/hda";
+ };
+ };
# Build boot scripts.
bootEnv = import ./boot-environment.nix {
- autoDetectRootDevice = false;
- inherit rootDevice;
stage2Init = ""; # Passed on the command line via Grub.
- readOnlyRoot = false;
+ inherit configuration;
};
# Extra kernel command line arguments.
@@ -34,12 +34,12 @@ rec {
inherit upstartJobs;
- systemConfiguration = pkgs.stdenvNew.mkDerivation {
+ system = pkgs.stdenvNew.mkDerivation {
name = "system-configuration";
builder = ./system-configuration.sh;
switchToConfiguration = ./switch-to-configuration.sh;
inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils;
- inherit grubDevice;
+ grubDevice = "/dev/hda"; # !!!
inherit bootStage2;
inherit activateConfiguration;
inherit grubMenuBuilder;
diff --git a/test.sh b/test.sh
index 6bb66bf742e..c50ebe907d1 100755
--- a/test.sh
+++ b/test.sh
@@ -1,4 +1,4 @@
#! /bin/sh
set -e
-nix-build configuration/system-configuration.nix -A systemConfiguration -K -k
+nix-build configuration/system-configuration.nix -A system -K -k
./result/bin/switch-to-configuration test