From 8f21b0119cdc252b44b1717cbce9541c668a5a4a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 16 Dec 2006 18:24:49 +0000 Subject: [PATCH] * Get the CD to build again. svn path=/nixos/trunk/; revision=7356 --- configuration/options.nix | 9 ++++ configuration/system.nix | 2 +- configuration/upstart.nix | 29 +++++----- installer/nixos-installer.nix | 8 ++- installer/nixos-installer.sh | 5 +- instances/rescue-cd.nix | 71 +++++++++++++++---------- upstart-jobs/tty-backgrounds-combine.sh | 6 +-- 7 files changed, 81 insertions(+), 49 deletions(-) diff --git a/configuration/options.nix b/configuration/options.nix index c8a2f07df01..54e0ea06227 100644 --- a/configuration/options.nix +++ b/configuration/options.nix @@ -189,4 +189,13 @@ } + { + name = ["services" "xserver" "enable"]; + default = false; + description = " + Whether to enable the X server. + "; + } + + ] diff --git a/configuration/system.nix b/configuration/system.nix index f030717491c..dad9fe4d3a3 100644 --- a/configuration/system.nix +++ b/configuration/system.nix @@ -108,7 +108,7 @@ rec { # The services (Upstart) configuration for the system. upstartJobs = import ./upstart.nix { - inherit pkgs nix splashThemes; + inherit config pkgs nix splashThemes; }; diff --git a/configuration/upstart.nix b/configuration/upstart.nix index 256804ad5a4..9f192bdd4a7 100644 --- a/configuration/upstart.nix +++ b/configuration/upstart.nix @@ -1,4 +1,4 @@ -{pkgs, nix, splashThemes}: +{config, pkgs, nix, splashThemes}: let @@ -6,6 +6,9 @@ let inherit (pkgs) runCommand; }; + optional = option: service: + if config.get option then [service] else []; + in import ../upstart-jobs/gather.nix { @@ -39,22 +42,11 @@ import ../upstart-jobs/gather.nix { dhcp = pkgs.dhcpWrapper; }) - # SSH daemon. - (import ../upstart-jobs/sshd.nix { - inherit (pkgs) openssh; - }) - # Nix daemon - required for multi-user Nix. (import ../upstart-jobs/nix-daemon.nix { inherit nix; }) - # X server. - (import ../upstart-jobs/xserver.nix { - inherit (pkgs) substituteAll; - inherit (pkgs.xorg) xorgserver xf86inputkeyboard xf86inputmouse xf86videovesa; - }) - # Transparent TTY backgrounds. (import ../upstart-jobs/tty-backgrounds.nix { inherit (pkgs) stdenv splashutils; @@ -71,6 +63,19 @@ import ../upstart-jobs/gather.nix { ] + # SSH daemon. + ++ optional ["services" "sshd" "enable"] + (import ../upstart-jobs/sshd.nix { + inherit (pkgs) openssh; + }) + + # X server. + ++ optional ["services" "xserver" "enable"] + (import ../upstart-jobs/xserver.nix { + inherit (pkgs) substituteAll; + inherit (pkgs.xorg) xorgserver xf86inputkeyboard xf86inputmouse xf86videovesa; + }) + # Handles the reboot/halt events. ++ (map (event: makeJob (import ../upstart-jobs/halt.nix { diff --git a/installer/nixos-installer.nix b/installer/nixos-installer.nix index 651efeabeb5..fd77c713c21 100644 --- a/installer/nixos-installer.nix +++ b/installer/nixos-installer.nix @@ -1,10 +1,14 @@ -{stdenv, runCommand, substituteAll, nix}: +{ stdenv, runCommand, substituteAll, nix +, # URL of the Nixpkgs distribution that the installer will pull. + # Leave empty for a pure source distribution. + nixpkgsURL ? "" +}: substituteAll { src = ./nixos-installer.sh; dir = "bin"; isExecutable = true; - inherit nix; + inherit nix nixpkgsURL; pathsFromGraph = ../helpers/paths-from-graph.sh; diff --git a/installer/nixos-installer.sh b/installer/nixos-installer.sh index 28b9b48cac3..f356462369e 100644 --- a/installer/nixos-installer.sh +++ b/installer/nixos-installer.sh @@ -106,8 +106,9 @@ cp /etc/resolv.conf $mountPoint/etc/ # Do a nix-pull to speed up building. -nixpkgsURL=http://nix.cs.uu.nl/dist/nix/nixpkgs-0.11pre6984 -chroot $mountPoint @nix@/bin/nix-pull $nixpkgsURL/MANIFEST +if test -n "@nixpkgsURL@"; then + chroot $mountPoint @nix@/bin/nix-pull @nixpkgsURL@/MANIFEST +fi # Build the specified Nix expression in the target store and install diff --git a/instances/rescue-cd.nix b/instances/rescue-cd.nix index bfe4dca3fd1..9d89380c768 100644 --- a/instances/rescue-cd.nix +++ b/instances/rescue-cd.nix @@ -1,53 +1,66 @@ -let - - # The label used to identify the installation CD. - cdromLabel = "NIXOS"; - -in - - # Build boot scripts for the CD that find the CD-ROM automatically. - with import ../configuration/boot-environment.nix { - autoDetectRootDevice = true; - rootLabel = cdromLabel; - stage2Init = "/init"; - readOnlyRoot = true; - }; - - rec { - inherit nixosInstaller bootStage1 upstartJobs; # !!! debug + + configuration = { + boot = { + autoDetectRootDevice = true; + readOnlyRoot = true; + # The label used to identify the installation CD. + rootLabel = "NIXOS"; + }; + services = { + sshd = { + enable = false; + }; + xserver = { + enable = false; + }; + }; + }; + system = import ../configuration/system.nix { + inherit configuration; + stage2Init = "/init"; + }; + + + pkgs = system.pkgs; + + # Since the CD is read-only, the mount points must be on disk. cdMountPoints = pkgs.runCommand "mount-points" {} " ensureDir $out cd $out mkdir proc sys tmp etc dev var mnt nix nix/var - touch $out/${cdromLabel} + touch $out/${configuration.boot.rootLabel} "; # We need a copy of the Nix expressions for Nixpkgs and NixOS on the # CD. We put them in a tarball because accessing that many small # files from a slow device like a CD-ROM takes too long. - makeTarball = tarName: input: pkgs.runCommand "tarball" " + makeTarball = tarName: input: pkgs.runCommand "tarball" {inherit tarName;} " ensureDir $out (cd ${input} && tar cvfj $out/${tarName} . \\ - --exclude '*~' --exclude '.svn' \\ + --exclude '*~' \\ --exclude 'pkgs' --exclude 'result') "; - # Put the current directory in the tarball. !!! This gives us a lot - # of crap (like .svn if this is a working copy). An "svn export" - # would be better, but that's impure. - nixosTarball = makeTarball "nixos.tar.bz2" ./.; + # Put the current directory in a tarball (making sure to filter + # out crap like the .svn directories). + nixosTarball = makeTarball "nixos.tar.bz2" (builtins.filterSource + (name: let base = baseNameOf (toString name); in base != ".svn" && base != "result") ./..); + + + # Get a recent copy of Nixpkgs. + nixpkgsRel = "nixpkgs-0.11pre7355"; + nixpkgsURL = http://nix.cs.uu.nl/dist/nix/ + nixpkgsRel; - nixpkgsTarball = pkgs.fetchurl { - url = http://nix.cs.uu.nl/dist/nix/nixpkgs-0.11pre7087/nixpkgs-0.11pre7087.tar.bz2; - md5 = "c5840fcd049d75e00ad856ecbbef6857"; + url = nixpkgsURL + "/" + nixpkgsRel + ".tar.bz2"; + md5 = "9d3e5e9f6ab64536803abf3f2e1c6056"; }; @@ -68,7 +81,7 @@ rec { { source = pkgs.kernel + "/vmlinuz"; target = "isolinux/vmlinuz"; } - { source = initialRamdisk + "/initrd"; + { source = system.initialRamdisk + "/initrd"; target = "isolinux/initrd"; } { source = cdMountPoints; @@ -82,7 +95,7 @@ rec { } ]; - init = bootStage2; + init = system.bootStage2; bootable = true; bootImage = "isolinux/isolinux.bin"; diff --git a/upstart-jobs/tty-backgrounds-combine.sh b/upstart-jobs/tty-backgrounds-combine.sh index 894952d6940..66113864f7b 100644 --- a/upstart-jobs/tty-backgrounds-combine.sh +++ b/upstart-jobs/tty-backgrounds-combine.sh @@ -24,14 +24,14 @@ for ((n = 0; n < ${#ttys[*]}; n++)); do echo "TTY $tty -> $theme" themeName=$(cd $theme && ls | grep -v default) - - ln -sf $theme/$themeName $out/$themeName + + ln -sfn $theme/$themeName $out/$themeName if test -e $out/$tty; then echo "Multiple themes defined for the same TTY!" exit 1 fi - ln -sf $themeName $out/$tty + ln -sfn $themeName $out/$tty done