* User configuration: use the `networking.hostname' option to

configure the host name.

svn path=/nixu/trunk/; revision=7150
This commit is contained in:
Eelco Dolstra 2006-11-27 16:26:51 +00:00
parent 67bada0886
commit 1a0fcfdf1a
4 changed files with 63 additions and 26 deletions

View File

@ -183,8 +183,7 @@ rec {
# everything else to bring up the system. # everything else to bring up the system.
bootStage2 = import ./boot-stage-2.nix { bootStage2 = import ./boot-stage-2.nix {
inherit (pkgs) genericSubstituter coreutils findutils inherit (pkgs) genericSubstituter coreutils findutils
utillinux kernel udev utillinux kernel udev upstart;
upstart;
inherit upstartJobs; inherit upstartJobs;
shell = pkgs.bash + "/bin/sh"; shell = pkgs.bash + "/bin/sh";
@ -218,6 +217,42 @@ rec {
]; ];
inherit readOnlyRoot; inherit readOnlyRoot;
hostName = config.get ["networking" "hostname"];
};
lib = import ./pkgs/lib;
config = rec {
# The user configuration.
config = {
networking = {
hostname = "vindaloo";
};
};
# The option declarations, i.e., option names with defaults and
# documentation.
declarations = import ./options.nix;
# Get the option named `name' from the user configuration, using
# its default value if it's not defined.
get = name:
let
sameName = lib.filter (opt: lib.eqLists opt.name name) declarations;
default =
if sameName == []
then abort ("Undeclared option `" + printName name + "'.")
else if !builtins.head sameName ? default
then abort ("Option `" + printName name + "' has no default.")
else (builtins.head sameName).default;
in lib.getAttr name default config;
printName = name: lib.concatStrings (lib.intersperse "." name);
}; };

View File

@ -157,7 +157,7 @@ EOF
# Set the host name. # Set the host name.
hostname nixos hostname @hostName@
# Start an interactive shell. # Start an interactive shell.

View File

@ -8,12 +8,14 @@
, # The Upstart job configuration. , # The Upstart job configuration.
upstartJobs upstartJobs
, hostName
}: }:
genericSubstituter { genericSubstituter {
src = ./boot-stage-2-init.sh; src = ./boot-stage-2-init.sh;
isExecutable = true; isExecutable = true;
inherit shell kernel upstart readOnlyRoot upstartJobs; inherit shell kernel upstart readOnlyRoot upstartJobs hostName;
path = [ path = [
coreutils coreutils
findutils findutils

View File

@ -1,22 +1,22 @@
[ [
(option { {
name = ["networking" "hostname"]; name = ["networking" "hostname"];
default = "nixos"; default = "nixos";
description = "The name of the machine." description = "The name of the machine.";
}) }
(option { {
name = ["networking" "useDHCP"]; name = ["networking" "useDHCP"];
default = true; default = true;
description = " description = "
Whether to use DHCP to obtain an IP adress and other Whether to use DHCP to obtain an IP adress and other
configuration for all network interfaces that are not manually configuration for all network interfaces that are not manually
configured. configured.
" ";
}) }
(option { {
name = ["networking" "interfaces"]; name = ["networking" "interfaces"];
default = []; default = [];
example = [ example = [
@ -30,10 +30,10 @@
The configuration for each network interface. If The configuration for each network interface. If
<option>networking.useDHCP</option> is true, then each interface <option>networking.useDHCP</option> is true, then each interface
not listed here will be configured using DHCP. not listed here will be configured using DHCP.
" ";
}) }
(option { {
name = ["filesystems" "mountPoints"]; name = ["filesystems" "mountPoints"];
example = [ example = [
{ device = "/dev/hda2"; { device = "/dev/hda2";
@ -46,27 +46,27 @@
\"/\"</literal>). This is the file system on which NixOS is (to \"/\"</literal>). This is the file system on which NixOS is (to
be) installed.. be) installed..
"; ";
}) }
(option { {
name = ["services" "syslogd" "tty"]; name = ["services" "syslogd" "tty"];
default = 10; default = 10;
description = " description = "
The tty device on which syslogd will print important log The tty device on which syslogd will print important log
messages. messages.
"; ";
}) }
(option { {
name = ["services" "mingetty" "ttys"]; name = ["services" "mingetty" "ttys"];
default = [1 2 3 4 5 6]; default = [1 2 3 4 5 6];
description = " description = "
The list of tty (virtual console) devices on which to start a The list of tty (virtual console) devices on which to start a
login prompt. login prompt.
"; ";
}) }
(option { {
name = ["services" "mingetty" "waitOnMounts"]; name = ["services" "mingetty" "waitOnMounts"];
default = false; default = false;
description = " description = "
@ -75,23 +75,23 @@
default we don't wait, but if for example your /home is on a default we don't wait, but if for example your /home is on a
separate partition, you may want to turn this on. separate partition, you may want to turn this on.
"; ";
}) }
(option { {
name = ["services" "sshd" "enable"]; name = ["services" "sshd" "enable"];
default = false; default = false;
description = " description = "
Whether to enable the Secure Shell daemon, which allows secure Whether to enable the Secure Shell daemon, which allows secure
remote logins. remote logins.
"; ";
}) }
(option { {
name = ["services" "sshd" "forwardX11"]; name = ["services" "sshd" "forwardX11"];
default = false; default = false;
description = " description = "
Whether to enable sshd to forward X11 connections. Whether to enable sshd to forward X11 connections.
"; ";
}) }
] ]