mirror of
https://github.com/NixOS/nix.git
synced 2024-11-26 00:32:28 +00:00
* Implemented Eelco V.'s `-p' command to switch profiles. It switches
the symlink ~/.nix-userenv to the given argument (which defaults to .../links/current). /etc/profile.d/nix-profile creates this symlink if it doesn't exist yet. Example use: $ nix-env -l my_profile -i foo.nix subversion quake $ nix-env -p my_profile I don't like the term "profile". Let's deprecate it :-)
This commit is contained in:
parent
0e68af0ce3
commit
f83c5e3e5f
@ -1,20 +1,11 @@
|
||||
#if test -z "$NIX_SET"; then
|
||||
if test -n "$HOME"; then
|
||||
NIX_LINK="$HOME/.nix-userenv"
|
||||
|
||||
# export NIX_SET=1
|
||||
if ! test -a "$NIX_LINK"; then
|
||||
echo "creating $NIX_LINK"
|
||||
_NIX_DEF_LINK=@localstatedir@/nix/links/current
|
||||
ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
|
||||
fi
|
||||
|
||||
NIX_LINKS=@localstatedir@/nix/links/current
|
||||
|
||||
export PATH=$NIX_LINKS/bin:@prefix@/bin:$PATH
|
||||
|
||||
# export LD_LIBRARY_PATH=$NIX_LINKS/lib:$LD_LIBRARY_PATH
|
||||
|
||||
export LIBRARY_PATH=$NIX_LINKS/lib:$LIBRARY_PATH
|
||||
|
||||
export C_INCLUDE_PATH=$NIX_LINKS/include:$C_INCLUDE_PATH
|
||||
export CPLUS_INCLUDE_PATH=$NIX_LINKS/include:$CPLUS_INCLUDE_PATH
|
||||
|
||||
export PKG_CONFIG_PATH=$NIX_LINKS/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||
|
||||
# export MANPATH=$NIX_LINKS/man:$MANPATH
|
||||
|
||||
#fi
|
||||
export PATH=$NIX_LINK/bin:@prefix@/bin:$PATH
|
||||
fi
|
||||
|
@ -12,6 +12,8 @@ Operations:
|
||||
The previous operations take a list of derivation names. The special
|
||||
name `*' may be used to indicate all derivations.
|
||||
|
||||
--profile / -p [FILE]: switch to specified user environment
|
||||
|
||||
--version: output version information
|
||||
--help: display help
|
||||
|
||||
|
@ -605,6 +605,26 @@ static void opQuery(Globals & globals,
|
||||
}
|
||||
|
||||
|
||||
static void opSwitchProfile(Globals & globals,
|
||||
Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (opFlags.size() > 0)
|
||||
throw UsageError(format("unknown flags `%1%'") % opFlags.front());
|
||||
if (opArgs.size() > 1)
|
||||
throw UsageError(format("--profile takes at most one argument"));
|
||||
|
||||
string linkPath =
|
||||
opArgs.size() == 0 ? globals.linkPath : opArgs.front();
|
||||
|
||||
string homeDir(getenv("HOME"));
|
||||
if (homeDir == "") throw Error("HOME environment variable not set");
|
||||
|
||||
string linkPathFinal = homeDir + "/.nix-userenv";
|
||||
|
||||
switchLink(linkPathFinal, linkPath);
|
||||
}
|
||||
|
||||
|
||||
void run(Strings args)
|
||||
{
|
||||
/* Use a higher default verbosity (lvlInfo). */
|
||||
@ -635,6 +655,8 @@ void run(Strings args)
|
||||
format("`%1%' requires an argument") % arg);
|
||||
globals.linkPath = absPath(*i);
|
||||
}
|
||||
else if (arg == "--profile" || arg == "-p")
|
||||
op = opSwitchProfile;
|
||||
else if (arg[0] == '-')
|
||||
opFlags.push_back(arg);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user