* Remove the use of the NIXPKGS and NIXOS environment variables.

Instead use $NIX_PATH.  NIXOS_CONFIG is still supported.

svn path=/nixos/trunk/; revision=32739
This commit is contained in:
Eelco Dolstra 2012-03-02 12:38:22 +00:00
parent d4f3443d33
commit 29d84af677
16 changed files with 34 additions and 149 deletions

View file

@ -1,4 +1,4 @@
{ configuration ? import ./lib/from-env.nix "NIXOS_CONFIG" /etc/nixos/configuration.nix { configuration ? import ./lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
, system ? builtins.currentSystem , system ? builtins.currentSystem
}: }:

View file

@ -107,27 +107,4 @@ for the same architecture as the host system.
</refsection> </refsection>
<refsection><title>Environment variables</title>
<variablelist>
<varlistentry>
<term><envar>NIXOS</envar></term>
<listitem>
<para>Path to the NixOS source tree. Defaults to
<filename>/etc/nixos/nixos</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>NIXPKGS_ALL</envar></term>
<listitem>
<para>Path to the Nixpkgs source tree. Defaults to
<filename>/etc/nixos/nixpkgs</filename>.</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
</refentry> </refentry>

View file

@ -109,27 +109,4 @@ for the same architecture as the host system.
</refsection> </refsection>
<refsection><title>Environment variables</title>
<variablelist>
<varlistentry>
<term><envar>NIXOS</envar></term>
<listitem>
<para>Path to the NixOS source tree. Defaults to
<filename>/etc/nixos/nixos</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>NIXPKGS_ALL</envar></term>
<listitem>
<para>Path to the Nixpkgs source tree. Defaults to
<filename>/etc/nixos/nixpkgs</filename>.</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
</refentry> </refentry>

View file

@ -111,22 +111,6 @@ by <command>nixos-hardware-scan</command>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><envar>NIXOS</envar></term>
<listitem>
<para>Path to the NixOS source tree. Defaults to
<filename>/etc/nixos/nixos</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>NIXPKGS</envar></term>
<listitem>
<para>Path to the Nixpkgs source tree. Defaults to
<filename>/etc/nixos/nixpkgs</filename>.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><envar>NIXOS_CONFIG</envar></term> <term><envar>NIXOS_CONFIG</envar></term>
<listitem> <listitem>

View file

@ -271,22 +271,6 @@ the Nix manual for details.</para>
<variablelist> <variablelist>
<varlistentry>
<term><envar>NIXOS</envar></term>
<listitem>
<para>Path to the NixOS source tree. Defaults to
<filename>/etc/nixos/nixos</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>NIXPKGS</envar></term>
<listitem>
<para>Path to the Nixpkgs source tree. Defaults to
<filename>/etc/nixos/nixpkgs</filename>.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><envar>NIXOS_CONFIG</envar></term> <term><envar>NIXOS_CONFIG</envar></term>
<listitem> <listitem>

View file

@ -1,6 +1,6 @@
{ nixpkgs, system }: { system }:
let pkgs = import nixpkgs { config = {}; inherit system; }; in let pkgs = import <nixpkgs> { config = {}; inherit system; }; in
with pkgs; with pkgs;
with import ../lib/qemu-flags.nix; with import ../lib/qemu-flags.nix;
@ -22,7 +22,7 @@ rec {
nodes: configurations: nodes: configurations:
import ./eval-config.nix { import ./eval-config.nix {
inherit nixpkgs system; inherit system;
modules = configurations ++ modules = configurations ++
[ ../modules/virtualisation/qemu-vm.nix [ ../modules/virtualisation/qemu-vm.nix
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs

View file

@ -3,7 +3,6 @@
# values. # values.
{ system ? builtins.currentSystem { system ? builtins.currentSystem
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
, pkgs ? null , pkgs ? null
, baseModules ? import ../modules/module-list.nix , baseModules ? import ../modules/module-list.nix
, extraArgs ? {} , extraArgs ? {}
@ -31,7 +30,7 @@ rec {
extraArgs = extraArgs_ // { extraArgs = extraArgs_ // {
inherit pkgs modules baseModules; inherit pkgs modules baseModules;
modulesPath = ../modules; modulesPath = ../modules;
pkgs_i686 = import nixpkgs { system = "i686-linux"; }; pkgs_i686 = import <nixpkgs> { system = "i686-linux"; };
}; };
# Import Nixpkgs, allowing the NixOS option nixpkgs.config to # Import Nixpkgs, allowing the NixOS option nixpkgs.config to
@ -47,15 +46,15 @@ rec {
pkgs = pkgs =
if pkgs_ != null if pkgs_ != null
then pkgs_ then pkgs_
else import nixpkgs ( else import <nixpkgs> (
let let
system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_; system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
nixpkgsOptions = (import ./eval-config.nix { nixpkgsOptions = (import ./eval-config.nix {
inherit system nixpkgs extraArgs modules; inherit system extraArgs modules;
# For efficiency, leave out most NixOS modules; they don't # For efficiency, leave out most NixOS modules; they don't
# define nixpkgs.config, so it's pointless to evaluate them. # define nixpkgs.config, so it's pointless to evaluate them.
baseModules = [ ../modules/misc/nixpkgs.nix ]; baseModules = [ ../modules/misc/nixpkgs.nix ];
pkgs = import nixpkgs { system = system_; config = {}; }; pkgs = import <nixpkgs> { system = system_; config = {}; };
}).optionDefinitions.nixpkgs; }).optionDefinitions.nixpkgs;
in in
{ {

View file

@ -1,6 +1,6 @@
{ nixpkgs, system }: { system }:
with import ./build-vms.nix { inherit nixpkgs system; }; with import ./build-vms.nix { inherit system; };
with pkgs; with pkgs;
rec { rec {
@ -118,7 +118,7 @@ rec {
makeTests = testsFun: lib.mapAttrs (name: complete) (call testsFun); makeTests = testsFun: lib.mapAttrs (name: complete) (call testsFun);
apply = makeTest; # compatibility apply = makeTest; # compatibility
call = f: f { inherit pkgs nixpkgs system; }; call = f: f { inherit pkgs system; };
complete = t: t // rec { complete = t: t // rec {
nodes = buildVirtualNetwork ( nodes = buildVirtualNetwork (

View file

@ -1,4 +1,4 @@
{ configuration ? import ../lib/from-env.nix "NIXOS_CONFIG" /etc/nixos/configuration.nix { configuration ? import ../lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
# []: display all options # []: display all options
# [<option names>]: display the selected options # [<option names>]: display the selected options

View file

@ -1,10 +1,9 @@
{ nixpkgs { system ? builtins.currentSystem
, system ? builtins.currentSystem
, networkExpr , networkExpr
}: }:
let nodes = import networkExpr; in let nodes = import networkExpr; in
with import ../../../../lib/testing.nix { inherit nixpkgs system; }; with import ../../../../lib/testing.nix { inherit system; };
(complete { inherit nodes; testScript = ""; }).driver (complete { inherit nodes; testScript = ""; }).driver

View file

@ -58,5 +58,5 @@ fi
# Build a network of VMs # Build a network of VMs
nix-build ${NIXOS:-/etc/nixos/nixos}/modules/installer/tools/nixos-build-vms/build-vms.nix \ nix-build '<nixos>/modules/installer/tools/nixos-build-vms/build-vms.nix' \
--argstr networkExpr $networkExpr --argstr nixpkgs "${NIXPKGS_ALL:-/etc/nixos/nixpkgs}" $noOutLinkArg $showTraceArg --argstr networkExpr $networkExpr $noOutLinkArg $showTraceArg

View file

@ -15,10 +15,6 @@ if test -z "$mountPoint"; then
mountPoint=/mnt mountPoint=/mnt
fi fi
if test -z "$NIXOS"; then
NIXOS=/etc/nixos/nixos
fi
# NIXOS_CONFIG is interpreted relative to $mountPoint. # NIXOS_CONFIG is interpreted relative to $mountPoint.
if test -z "$NIXOS_CONFIG"; then if test -z "$NIXOS_CONFIG"; then
NIXOS_CONFIG=/etc/nixos/configuration.nix NIXOS_CONFIG=/etc/nixos/configuration.nix
@ -34,20 +30,12 @@ if ! grep -F -q " $mountPoint " /proc/mounts; then
exit 1 exit 1
fi fi
if ! test -e "$NIXOS"; then
echo "NixOS source directory $NIXOS doesn't exist"
exit 1
fi
if ! test -e "$mountPoint/$NIXOS_CONFIG"; then if ! test -e "$mountPoint/$NIXOS_CONFIG"; then
echo "configuration file $mountPoint/$NIXOS_CONFIG doesn't exist" echo "configuration file $mountPoint/$NIXOS_CONFIG doesn't exist"
exit 1 exit 1
fi fi
NIXOS=$(readlink -f "$NIXOS")
# Enable networking in the chroot. # Enable networking in the chroot.
mkdir -m 0755 -p $mountPoint/etc mkdir -m 0755 -p $mountPoint/etc
touch /etc/resolv.conf touch /etc/resolv.conf
@ -153,10 +141,9 @@ fi
# Build the specified Nix expression in the target store and install # Build the specified Nix expression in the target store and install
# it into the system configuration profile. # it into the system configuration profile.
echo "building the system configuration..." echo "building the system configuration..."
NIXPKGS=/mnt/etc/nixos/nixpkgs chroot $mountPoint @nix@/bin/nix-env \ NIX_PATH=nixpkgs=/mnt/etc/nixos/nixpkgs:nixos=/mnt/etc/nixos/nixos \
-p /nix/var/nix/profiles/system \ chroot $mountPoint @nix@/bin/nix-env \
-f "/mnt$NIXOS" \ -p /nix/var/nix/profiles/system -f '<nixos>' --set -A system
--set -A system
# Make a backup of the old NixOS/Nixpkgs sources. # Make a backup of the old NixOS/Nixpkgs sources.
@ -176,8 +163,8 @@ fi
# Copy the NixOS/Nixpkgs sources to the target. # Copy the NixOS/Nixpkgs sources to the target.
cp -prd $NIXOS $targetNixos cp -prd /etc/nixos/nixos $targetNixos
if test -e /etc/nixos/nixpkgs; then if [ -e /etc/nixos/nixpkgs ]; then
cp -prd /etc/nixos/nixpkgs $targetNixpkgs cp -prd /etc/nixos/nixpkgs $targetNixpkgs
fi fi

View file

@ -4,10 +4,7 @@
# file to be overridden. # file to be overridden.
: ${mountPoint=/mnt} : ${mountPoint=/mnt}
: ${NIXOS=/etc/nixos/nixos}
: ${NIXOS_CONFIG=/etc/nixos/configuration.nix} : ${NIXOS_CONFIG=/etc/nixos/configuration.nix}
: ${NIXPKGS=/etc/nixos/nixpkgs}
export NIXOS
usage () { usage () {
echo 1>&2 " echo 1>&2 "
@ -38,9 +35,7 @@ Options:
Environment variables affecting $0: Environment variables affecting $0:
\$mountPoint Path to the target file system. \$mountPoint Path to the target file system.
\$NIXOS Path where the NixOS repository is located.
\$NIXOS_CONFIG Path to your configuration file. \$NIXOS_CONFIG Path to your configuration file.
\$NIXPKGS Path to Nix packages.
" "
@ -190,12 +185,6 @@ nixMap() {
} }
if $install; then if $install; then
if test -e "$mountPoint$NIXOS"; then
export NIXOS="$mountPoint$NIXOS"
fi
if test -e "$mountPoint$NIXPKGS"; then
export NIXPKGS="$mountPoint$NIXPKGS"
fi
export NIXOS_CONFIG="$mountPoint$NIXOS_CONFIG" export NIXOS_CONFIG="$mountPoint$NIXOS_CONFIG"
fi fi
@ -319,8 +308,8 @@ if $xml; then
evalNix --xml --no-location <<EOF evalNix --xml --no-location <<EOF
let let
reach = attrs: attrs${option:+.$option}; reach = attrs: attrs${option:+.$option};
nixos = import $NIXOS {}; nixos = <nixos>;
nixpkgs = import $NIXPKGS {}; nixpkgs = <nixpkgs>;
sources = builtins.map (f: f.source); sources = builtins.map (f: f.source);
opt = reach nixos.eval.options; opt = reach nixos.eval.options;
cfg = reach nixos.config; cfg = reach nixos.config;

View file

@ -1,12 +1,5 @@
#! @shell@ -e #! @shell@ -e
# Allow the location of NixOS sources and the system configuration
# file to be overridden.
NIXOS=${NIXOS:-/etc/nixos/nixos}
NIXPKGS=${NIXPKGS:-/etc/nixos/nixpkgs}
NIXOS_CONFIG=${NIXOS_CONFIG:-/etc/nixos/configuration.nix}
export NIXPKGS # must be exported so that a non default location is passed to nixos/default.nix
showSyntax() { showSyntax() {
# !!! more or less cut&paste from # !!! more or less cut&paste from
# system/switch-to-configuration.sh (which we call, of course). # system/switch-to-configuration.sh (which we call, of course).
@ -45,8 +38,7 @@ Various nix-build options are also accepted, in particular:
Environment variables affecting nixos-rebuild: Environment variables affecting nixos-rebuild:
\$NIXOS path to the NixOS source tree \$NIX_PATH Nix expression search path
\$NIXPKGS path to the Nixpkgs source tree
\$NIXOS_CONFIG path to the NixOS system configuration specification \$NIXOS_CONFIG path to the NixOS system configuration specification
EOF EOF
exit 1 exit 1
@ -130,7 +122,7 @@ fi
# Pull the manifests defined in the configuration (the "manifests" # Pull the manifests defined in the configuration (the "manifests"
# attribute). Wonderfully hacky. # attribute). Wonderfully hacky.
if test -n "$pullManifest"; then if test -n "$pullManifest"; then
manifests=$(nix-instantiate --eval-only --xml --strict $NIXOS -A manifests \ manifests=$(nix-instantiate --eval-only --xml --strict '<nixos>' -A manifests \
| grep '<string' | sed 's^.*"\(.*\)".*^\1^g') | grep '<string' | sed 's^.*"\(.*\)".*^\1^g')
mkdir -p /nix/var/nix/channel-cache mkdir -p /nix/var/nix/channel-cache
@ -147,9 +139,9 @@ if [ "$action" = pull ]; then exit 0; fi
# more conservative. # more conservative.
if test -n "$buildNix"; then if test -n "$buildNix"; then
echo "building Nix..." >&2 echo "building Nix..." >&2
if ! nix-build $NIXOS -A config.environment.nix -o $tmpDir/nix $extraBuildFlags > /dev/null; then if ! nix-build '<nixos>' -A config.environment.nix -o $tmpDir/nix $extraBuildFlags > /dev/null; then
if ! nix-build $NIXOS -A nixFallback -o $tmpDir/nix $extraBuildFlags > /dev/null; then if ! nix-build '<nixos>' -A nixFallback -o $tmpDir/nix $extraBuildFlags > /dev/null; then
nix-build $NIXPKGS -A nixUnstable -o $tmpDir/nix $extraBuildFlags > /dev/null nix-build '<nixpkgs>' -A nixUnstable -o $tmpDir/nix $extraBuildFlags > /dev/null
fi fi
fi fi
PATH=$tmpDir/nix/bin:$PATH PATH=$tmpDir/nix/bin:$PATH
@ -162,16 +154,16 @@ fi
if test -z "$rollback"; then if test -z "$rollback"; then
echo "building the system configuration..." >&2 echo "building the system configuration..." >&2
if test "$action" = switch -o "$action" = boot; then if test "$action" = switch -o "$action" = boot; then
nix-env -p /nix/var/nix/profiles/system -f $NIXOS --set -A system $extraBuildFlags nix-env -p /nix/var/nix/profiles/system -f '<nixos>' --set -A system $extraBuildFlags
pathToConfig=/nix/var/nix/profiles/system pathToConfig=/nix/var/nix/profiles/system
elif test "$action" = test -o "$action" = build -o "$action" = dry-run; then elif test "$action" = test -o "$action" = build -o "$action" = dry-run; then
nix-build $NIXOS -A system -K -k $extraBuildFlags > /dev/null nix-build '<nixos>' -A system -K -k $extraBuildFlags > /dev/null
pathToConfig=./result pathToConfig=./result
elif [ "$action" = build-vm ]; then elif [ "$action" = build-vm ]; then
nix-build $NIXOS -A vm -K -k $extraBuildFlags > /dev/null nix-build '<nixos>' -A vm -K -k $extraBuildFlags > /dev/null
pathToConfig=./result pathToConfig=./result
elif [ "$action" = build-vm-with-bootloader ]; then elif [ "$action" = build-vm-with-bootloader ]; then
nix-build $NIXOS -A vmWithBootLoader -K -k $extraBuildFlags > /dev/null nix-build '<nixos>' -A vmWithBootLoader -K -k $extraBuildFlags > /dev/null
pathToConfig=./result pathToConfig=./result
else else
showSyntax showSyntax

View file

@ -10,7 +10,6 @@ fi
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib:/var/run/opengl-driver-32/lib # !!! only set if needed export LD_LIBRARY_PATH=/var/run/opengl-driver/lib:/var/run/opengl-driver-32/lib # !!! only set if needed
export MODULE_DIR=@modulesTree@/lib/modules export MODULE_DIR=@modulesTree@/lib/modules
export NIXPKGS_CONFIG=/nix/etc/config.nix export NIXPKGS_CONFIG=/nix/etc/config.nix
export NIXPKGS_ALL=/etc/nixos/nixpkgs
export NIX_PATH=nixpkgs=/etc/nixos/nixpkgs:nixos=/etc/nixos/nixos:nixos-config=/etc/nixos/configuration.nix:services=/etc/nixos/services export NIX_PATH=nixpkgs=/etc/nixos/nixpkgs:nixos=/etc/nixos/nixos:nixos-config=/etc/nixos/configuration.nix:services=/etc/nixos/services
export PAGER="less -R" export PAGER="less -R"
export EDITOR=nano export EDITOR=nano

View file

@ -1,8 +1,6 @@
{ nixpkgs ? ../../nixpkgs { system ? builtins.currentSystem }:
, system ? builtins.currentSystem
}:
with import ../lib/testing.nix { inherit nixpkgs system; }; with import ../lib/testing.nix { inherit system; };
{ {
avahi = makeTest (import ./avahi.nix); avahi = makeTest (import ./avahi.nix);