From 463cf8efdd974738ae30ed9a7712fd3d9d8ee922 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 10 Jun 2009 12:34:58 +0000 Subject: [PATCH] * Provide a /etc/nixos/configuration.nix in the booted CD to make nixos-rebuild work. This makes it a true live CD. svn path=/nixos/branches/modular-nixos/; revision=15922 --- modules/installer/cd-dvd/installation-cd.nix | 37 ++++++++++++++++++-- modules/services/misc/rogue.nix | 1 + 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/installer/cd-dvd/installation-cd.nix b/modules/installer/cd-dvd/installation-cd.nix index 68d2a76f93a..acb62db01cf 100644 --- a/modules/installer/cd-dvd/installation-cd.nix +++ b/modules/installer/cd-dvd/installation-cd.nix @@ -33,6 +33,27 @@ let # Put Nixpkgs in a tarball. nixpkgsTarball = makeTarball "nixpkgs.tar.bz2" (pkgs.lib.cleanSource pkgs.path); + + # A dummy /etc/nixos/configuration.nix in the booted CD that + # rebuilds the CD's configuration (and allows the configuration to + # be modified, of course, providing a true live CD). Problem is + # that we don't really know how the CD was built - the Nix + # expression language doesn't allow us to query the expression being + # evaluated. So we'll just hope for the best. + dummyConfiguration = pkgs.writeText "configuration.nix" + '' + {config, pkgs, ...}: + + { + require = [./nixos/modules/installer/cd-dvd/installation-cd.nix]; + + # Add your own options below and run "nixos-rebuild switch". + # E.g., + # services.sshd.enable = true; + } + ''; + + in { @@ -54,6 +75,7 @@ in # Don't include X libraries. services.sshd.forwardX11 = false; fonts.enableFontConfig = false; + fonts.enableCoreFonts = false; # Show the manual. services.showManual.enable = true; @@ -128,20 +150,31 @@ in # installation. installer.nixpkgsURL = http://nixos.org/releases/nixpkgs/channels/nixpkgs-unstable; - # Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required - # for nixos-install. boot.postBootCommands = '' export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH + # Provide a mount point for nixos-install. mkdir -p /mnt + # Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required + # for nixos-install. echo "unpacking the NixOS/Nixpkgs sources..." mkdir -p /etc/nixos/nixos tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos mkdir -p /etc/nixos/nixpkgs tar xjf ${nixpkgsTarball}/nixpkgs.tar.bz2 -C /etc/nixos/nixpkgs chown -R root.root /etc/nixos + + # Provide a configuration for the CD/DVD itself, to allow users + # to run nixos-rebuild to change the configuration of the + # running system on the CD/DVD. + cp ${dummyConfiguration} /etc/nixos/configuration.nix + + # nixos-rebuild also requires a "system" profile and an + # /etc/NIXOS tag. + touch /etc/NIXOS + ${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set /var/run/current-system ''; # Some more help text. diff --git a/modules/services/misc/rogue.nix b/modules/services/misc/rogue.nix index ddda413727a..5ae14fbee22 100644 --- a/modules/services/misc/rogue.nix +++ b/modules/services/misc/rogue.nix @@ -41,6 +41,7 @@ pkgs.lib.mkIf cfg.enable { start on udev stop on shutdown + respawn ${pkgs.rogue}/bin/rogue < /dev/tty${toString cfg.ttyNumber} > /dev/tty${toString cfg.ttyNumber} 2>&1 ''; };