From 1a6e1a43dc0000acc67c64c7be80046c64644182 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Mon, 12 May 2008 07:12:18 +0000 Subject: [PATCH] Added closed-install example of configurable Live DVD. Tested: virtual network of two QEmu-s, one is booted from that LiveDVD, another executes one scripted process and forces first to install NixOS. svn path=/nixos/trunk/; revision=11816 --- configuration/closed-install.nix | 57 +++++++++++++++++++ .../examples/closed-install-configuration.nix | 32 +++++++++++ configuration/rescue-cd-configurable.nix | 31 ++++++++++ 3 files changed, 120 insertions(+) create mode 100644 configuration/closed-install.nix create mode 100644 configuration/examples/closed-install-configuration.nix diff --git a/configuration/closed-install.nix b/configuration/closed-install.nix new file mode 100644 index 000000000000..16d65142346b --- /dev/null +++ b/configuration/closed-install.nix @@ -0,0 +1,57 @@ +{platform ? __currentSystem} : +let + isoFun = import ./rescue-cd-configurable.nix; +in +(isoFun { + inherit platform; + lib = (import ../pkgs/lib); + + networkNixpkgs = ""; + manualEnabled = true; + rogueEnabled = false; + sshdEnabled = true; + fontConfigEnabled = false; + sudoEnable = true; + includeMemtest = false; + includeStdenv = true; + includeBuildDeps = true; + + /* + If anyone uses that DVD on live + computer, use DHCP; but also add + a rogue address for tests in virtual + networks without DHCP at all. + */ + addIP = "10.0.253.251"; + netmask = "255.255.0.0"; + + kernel = pkgs: ( + pkgs.aggregateModules + [pkgs.kernel] + ); + + packages = pkgs : [ + pkgs.patch + pkgs.irssi + pkgs.subversion + pkgs.w3m + pkgs.utillinuxCurses + pkgs.wpa_supplicant + pkgs.emacs + pkgs.vimHugeX + ]; + + /* + The goal is remotely controlled + installation (maybe over virtual + networking with QEmu without human + interaction), so let's make ssh + work without manual password entry + */ + additionalFiles = [ + { + source = /var/certs/ssh/id_livedvd.pub; + target = "/root/.ssh/authorized_keys"; + } + ]; +}).rescueCD diff --git a/configuration/examples/closed-install-configuration.nix b/configuration/examples/closed-install-configuration.nix new file mode 100644 index 000000000000..807bf73d0e60 --- /dev/null +++ b/configuration/examples/closed-install-configuration.nix @@ -0,0 +1,32 @@ +{ + boot = { + grubDevice = "/dev/sda"; + copyKernels = true; + bootMount = "(hd0,0)"; + }; + + fileSystems = [ + { mountPoint = "/"; + device = "/dev/sda3"; + } + { mountPoint = "/boot"; + device = "/dev/sda1"; + neededForBoot = true; + } + ]; + + swapDevices = [ + { device = "/dev/sda2"; } + ]; + + services = { + sshd = { + enable = true; + }; + }; + + fonts = { + enableFontConfig = false; + }; + +} diff --git a/configuration/rescue-cd-configurable.nix b/configuration/rescue-cd-configurable.nix index 1bf185d2c5a6..9488254755e0 100644 --- a/configuration/rescue-cd-configurable.nix +++ b/configuration/rescue-cd-configurable.nix @@ -24,6 +24,20 @@ */ ,configList ? (configuration : []) ,aufs ? true + + /* + Address/netmask to be always added, whatever + network-interfaces configure is kept + */ + ,addIP ? "" + ,netmask ? "255.255.255.0" + /* To select interface to bind address to */ + ,ifName ? "eth0" + + /* + list of: {source, target} + */ + ,additionalFiles ? [] }: let ttyCount = lib.fold builtins.add 0 [ @@ -205,6 +219,21 @@ rec { ''; } ) + + ++ + + (lib.optional (addIP != "") + { + name = "add-IP-adress"; + job = '' + start on network-interfaces/started + script + ${pkgs.nettools}/sbin/ifconfig ${ifName} add ${addIP} up + ${pkgs.nettools}/sbin/ifconfig ${ifName}:0 netmask ${netmask} up + end script + ''; + } + ) ; # And a background to go with that. @@ -395,6 +424,8 @@ rec { target = "boot/memtest.bin"; } ) + ++ + additionalFiles ; };