From e060b99c52911a97e4b1c518e2e90517a6e22677 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Dec 2006 00:16:20 +0000 Subject: [PATCH] * Removed boot.rootDevice, instead obtain the root device from the filesystems option (specifically the file system with mountPoint == "/"). svn path=/nixos/trunk/; revision=7447 --- configuration/config.nix | 11 +++++----- configuration/options.nix | 41 ++++++++++++++++++++---------------- configuration/system.nix | 5 ++++- instances/examples/basic.nix | 8 ++++++- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/configuration/config.nix b/configuration/config.nix index 705b44407af3..46b9b1e76b8c 100644 --- a/configuration/config.nix +++ b/configuration/config.nix @@ -15,13 +15,14 @@ rec { # its default value if it's not defined. get = name: let - sameName = lib.filter (opt: lib.eqLists opt.name name) declarations; + decl = + lib.findSingle (decl: lib.eqLists decl.name name) + (abort ("Undeclared option `" + printName name + "'.")) + declarations; default = - if sameName == [] - then abort ("Undeclared option `" + printName name + "'.") - else if !builtins.head sameName ? default + if !decl ? default then abort ("Option `" + printName name + "' has no default.") - else (builtins.head sameName).default; + else decl.default; in lib.getAttr name default config; printName = name: lib.concatStrings (lib.intersperse "." name); diff --git a/configuration/options.nix b/configuration/options.nix index cd7f2a929d88..ec4bc85b9c48 100644 --- a/configuration/options.nix +++ b/configuration/options.nix @@ -13,17 +13,8 @@ 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. + device with the right label. If this option is off, then a root + file system must be specified using . "; } @@ -150,17 +141,31 @@ { - name = ["filesystems" "mountPoints"]; + name = ["filesystems"]; example = [ - { device = "/dev/hda2"; - mountPoint = "/"; + { mountPoint = "/"; + device = "/dev/hda1"; + } + { mountPoint = "/data"; + device = "/dev/hda2"; + filesystem = "ext3"; + autoMount = true; + options = "data=journal"; } ]; description = " - The file systems to be mounted by NixOS. It must include an - entry for the root directory (mountPoint = - \"/\"). This is the file system on which NixOS is (to - be) installed.. + The file systems to be mounted. It must include an entry for + the root directory (mountPoint = \"/\"). + Each entry in the list is an attribute set with the following + fields: mountPoint, + device, filesystem (a file + system type recognised by mount; defaults to + \"auto\"), autoMount (a + boolean indicating whether the file system is mounted + automatically; defaults to true) and + options (the mount options passed to + mount using the flag; + defaults to \"\"). "; } diff --git a/configuration/system.nix b/configuration/system.nix index 133c12b935c2..090ecc9b3a54 100644 --- a/configuration/system.nix +++ b/configuration/system.nix @@ -73,7 +73,10 @@ rec { inherit (pkgsDiet) module_init_tools; inherit extraUtils; autoDetectRootDevice = config.get ["boot" "autoDetectRootDevice"]; - rootDevice = config.get ["boot" "rootDevice"]; + rootDevice = + (pkgs.library.findSingle (fs: fs.mountPoint == "/") + (abort "No root mount point declared.") + (config.get ["filesystems"])).device; rootLabel = config.get ["boot" "rootLabel"]; inherit stage2Init; modulesDir = modulesClosure; diff --git a/instances/examples/basic.nix b/instances/examples/basic.nix index eedfa5f74b6f..f77b8101bb70 100644 --- a/instances/examples/basic.nix +++ b/instances/examples/basic.nix @@ -1,10 +1,16 @@ { boot = { autoDetectRootDevice = false; - rootDevice = "/dev/hda1"; readOnlyRoot = false; grubDevice = "/dev/hda"; }; + + filesystems = [ + { mountPoint = "/"; + device = "/dev/hda1"; + } + ]; + services = { sshd = { enable = true;