1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00

* 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
}:

View file

@ -107,27 +107,4 @@ for the same architecture as the host system.
</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>

View file

@ -109,27 +109,4 @@ for the same architecture as the host system.
</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>

View file

@ -111,22 +111,6 @@ by <command>nixos-hardware-scan</command>.</para>
</listitem>
</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>
<term><envar>NIXOS_CONFIG</envar></term>
<listitem>

View file

@ -271,22 +271,6 @@ the Nix manual for details.</para>
<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>
<term><envar>NIXOS_CONFIG</envar></term>
<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 import ../lib/qemu-flags.nix;
@ -22,7 +22,7 @@ rec {
nodes: configurations:
import ./eval-config.nix {
inherit nixpkgs system;
inherit system;
modules = configurations ++
[ ../modules/virtualisation/qemu-vm.nix
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs

View file

@ -3,7 +3,6 @@
# values.
{ system ? builtins.currentSystem
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
, pkgs ? null
, baseModules ? import ../modules/module-list.nix
, extraArgs ? {}
@ -31,7 +30,7 @@ rec {
extraArgs = extraArgs_ // {
inherit pkgs modules baseModules;
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
@ -47,15 +46,15 @@ rec {
pkgs =
if pkgs_ != null
then pkgs_
else import nixpkgs (
else import <nixpkgs> (
let
system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
nixpkgsOptions = (import ./eval-config.nix {
inherit system nixpkgs extraArgs modules;
inherit system extraArgs modules;
# For efficiency, leave out most NixOS modules; they don't
# define nixpkgs.config, so it's pointless to evaluate them.
baseModules = [ ../modules/misc/nixpkgs.nix ];
pkgs = import nixpkgs { system = system_; config = {}; };
pkgs = import <nixpkgs> { system = system_; config = {}; };
}).optionDefinitions.nixpkgs;
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;
rec {
@ -118,7 +118,7 @@ rec {
makeTests = testsFun: lib.mapAttrs (name: complete) (call testsFun);
apply = makeTest; # compatibility
call = f: f { inherit pkgs nixpkgs system; };
call = f: f { inherit pkgs system; };
complete = t: t // rec {
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
# [<option names>]: display the selected options

View file

@ -1,10 +1,9 @@
{ nixpkgs
, system ? builtins.currentSystem
{ system ? builtins.currentSystem
, networkExpr
}:
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

View file

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

View file

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

View file

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

View file

@ -1,12 +1,5 @@
#! @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() {
# !!! more or less cut&paste from
# 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:
\$NIXOS path to the NixOS source tree
\$NIXPKGS path to the Nixpkgs source tree
\$NIX_PATH Nix expression search path
\$NIXOS_CONFIG path to the NixOS system configuration specification
EOF
exit 1
@ -130,7 +122,7 @@ fi
# Pull the manifests defined in the configuration (the "manifests"
# attribute). Wonderfully hacky.
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')
mkdir -p /nix/var/nix/channel-cache
@ -147,9 +139,9 @@ if [ "$action" = pull ]; then exit 0; fi
# more conservative.
if test -n "$buildNix"; then
echo "building Nix..." >&2
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
nix-build $NIXPKGS -A nixUnstable -o $tmpDir/nix $extraBuildFlags > /dev/null
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
nix-build '<nixpkgs>' -A nixUnstable -o $tmpDir/nix $extraBuildFlags > /dev/null
fi
fi
PATH=$tmpDir/nix/bin:$PATH
@ -162,16 +154,16 @@ fi
if test -z "$rollback"; then
echo "building the system configuration..." >&2
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
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
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
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
else
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 MODULE_DIR=@modulesTree@/lib/modules
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 PAGER="less -R"
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);