From 1a0fcfdf1a890881aea0ff86ee97f7845bb4beaa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 27 Nov 2006 16:26:51 +0000 Subject: * User configuration: use the `networking.hostname' option to configure the host name. svn path=/nixu/trunk/; revision=7150 --- test/boot-environment.nix | 39 +++++++++++++++++++++++++++++++++++++-- test/boot-stage-2-init.sh | 2 +- test/boot-stage-2.nix | 4 +++- test/options.nix | 44 ++++++++++++++++++++++---------------------- 4 files changed, 63 insertions(+), 26 deletions(-) (limited to 'test') diff --git a/test/boot-environment.nix b/test/boot-environment.nix index a9d85eb773c..78086e99cfc 100644 --- a/test/boot-environment.nix +++ b/test/boot-environment.nix @@ -183,8 +183,7 @@ rec { # everything else to bring up the system. bootStage2 = import ./boot-stage-2.nix { inherit (pkgs) genericSubstituter coreutils findutils - utillinux kernel udev - upstart; + utillinux kernel udev upstart; inherit upstartJobs; shell = pkgs.bash + "/bin/sh"; @@ -218,6 +217,42 @@ rec { ]; 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); + }; diff --git a/test/boot-stage-2-init.sh b/test/boot-stage-2-init.sh index 58277751680..57a6a20a71f 100644 --- a/test/boot-stage-2-init.sh +++ b/test/boot-stage-2-init.sh @@ -157,7 +157,7 @@ EOF # Set the host name. -hostname nixos +hostname @hostName@ # Start an interactive shell. diff --git a/test/boot-stage-2.nix b/test/boot-stage-2.nix index 1bf8856f480..7d73e37cb4f 100644 --- a/test/boot-stage-2.nix +++ b/test/boot-stage-2.nix @@ -8,12 +8,14 @@ , # The Upstart job configuration. upstartJobs + +, hostName }: genericSubstituter { src = ./boot-stage-2-init.sh; isExecutable = true; - inherit shell kernel upstart readOnlyRoot upstartJobs; + inherit shell kernel upstart readOnlyRoot upstartJobs hostName; path = [ coreutils findutils diff --git a/test/options.nix b/test/options.nix index 2b58044c5ed..4cd2f3a7343 100644 --- a/test/options.nix +++ b/test/options.nix @@ -1,22 +1,22 @@ -[ +[ - (option { + { name = ["networking" "hostname"]; default = "nixos"; - description = "The name of the machine." - }) + description = "The name of the machine."; + } - (option { + { name = ["networking" "useDHCP"]; default = true; description = " Whether to use DHCP to obtain an IP adress and other configuration for all network interfaces that are not manually configured. - " - }) + "; + } - (option { + { name = ["networking" "interfaces"]; default = []; example = [ @@ -30,10 +30,10 @@ The configuration for each network interface. If is true, then each interface not listed here will be configured using DHCP. - " - }) + "; + } - (option { + { name = ["filesystems" "mountPoints"]; example = [ { device = "/dev/hda2"; @@ -46,27 +46,27 @@ \"/\"). This is the file system on which NixOS is (to be) installed.. "; - }) + } - (option { + { name = ["services" "syslogd" "tty"]; default = 10; description = " The tty device on which syslogd will print important log messages. "; - }) + } - (option { + { name = ["services" "mingetty" "ttys"]; default = [1 2 3 4 5 6]; description = " The list of tty (virtual console) devices on which to start a login prompt. "; - }) + } - (option { + { name = ["services" "mingetty" "waitOnMounts"]; default = false; description = " @@ -75,23 +75,23 @@ default we don't wait, but if for example your /home is on a separate partition, you may want to turn this on. "; - }) + } - (option { + { name = ["services" "sshd" "enable"]; default = false; description = " Whether to enable the Secure Shell daemon, which allows secure remote logins. "; - }) + } - (option { + { name = ["services" "sshd" "forwardX11"]; default = false; description = " Whether to enable sshd to forward X11 connections. "; - }) + } ] -- cgit 1.4.1