mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
nix-env: Create ~/.nix-defexpr automatically
This commit is contained in:
parent
61a6176aca
commit
c9159f86cc
3 changed files with 12 additions and 30 deletions
|
@ -5,18 +5,6 @@ __ETC_PROFILE_NIX_SOURCED=1
|
||||||
export NIX_USER_PROFILE_DIR="@localstatedir@/nix/profiles/per-user/$USER"
|
export NIX_USER_PROFILE_DIR="@localstatedir@/nix/profiles/per-user/$USER"
|
||||||
export NIX_PROFILES="@localstatedir@/nix/profiles/default $HOME/.nix-profile"
|
export NIX_PROFILES="@localstatedir@/nix/profiles/default $HOME/.nix-profile"
|
||||||
|
|
||||||
if test -w $HOME; then
|
|
||||||
# Set up a default Nix expression from which to install stuff.
|
|
||||||
if [ ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr ]; then
|
|
||||||
rm -f $HOME/.nix-defexpr
|
|
||||||
mkdir -p $HOME/.nix-defexpr
|
|
||||||
if [ "$USER" != root ]; then
|
|
||||||
ln -s @localstatedir@/nix/profiles/per-user/root/channels $HOME/.nix-defexpr/channels_root
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
||||||
if [ ! -z "${NIX_SSL_CERT_FILE:-}" ]; then
|
if [ ! -z "${NIX_SSL_CERT_FILE:-}" ]; then
|
||||||
: # Allow users to override the NIX_SSL_CERT_FILE
|
: # Allow users to override the NIX_SSL_CERT_FILE
|
||||||
|
|
|
@ -7,17 +7,6 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
|
||||||
|
|
||||||
NIX_USER_PROFILE_DIR=@localstatedir@/nix/profiles/per-user/$USER
|
NIX_USER_PROFILE_DIR=@localstatedir@/nix/profiles/per-user/$USER
|
||||||
|
|
||||||
if [ -w "$HOME" ]; then
|
|
||||||
# Set up a default Nix expression from which to install stuff.
|
|
||||||
__nix_defexpr="$HOME"/.nix-defexpr
|
|
||||||
[ -L "$__nix_defexpr" ] && rm -f "$__nix_defexpr"
|
|
||||||
mkdir -m 0755 -p "$__nix_defexpr"
|
|
||||||
if [ "$USER" != root ] && [ ! -L "$__nix_defexpr"/channels_root ]; then
|
|
||||||
ln -s @localstatedir@/nix/profiles/per-user/root/channels "$__nix_defexpr"/channels_root
|
|
||||||
fi
|
|
||||||
unset __nix_defexpr
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Append ~/.nix-defexpr/channels to $NIX_PATH so that <nixpkgs>
|
# Append ~/.nix-defexpr/channels to $NIX_PATH so that <nixpkgs>
|
||||||
# paths work when the user has fetched the Nixpkgs channel.
|
# paths work when the user has fetched the Nixpkgs channel.
|
||||||
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels
|
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels
|
||||||
|
|
|
@ -192,12 +192,6 @@ static void loadDerivations(EvalState & state, Path nixExprPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Path getDefNixExprPath()
|
|
||||||
{
|
|
||||||
return getHome() + "/.nix-defexpr";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static long getPriority(EvalState & state, DrvInfo & drv)
|
static long getPriority(EvalState & state, DrvInfo & drv)
|
||||||
{
|
{
|
||||||
return drv.queryMetaInt("priority", 0);
|
return drv.queryMetaInt("priority", 0);
|
||||||
|
@ -1327,9 +1321,20 @@ static int _main(int argc, char * * argv)
|
||||||
Globals globals;
|
Globals globals;
|
||||||
|
|
||||||
globals.instSource.type = srcUnknown;
|
globals.instSource.type = srcUnknown;
|
||||||
globals.instSource.nixExprPath = getDefNixExprPath();
|
globals.instSource.nixExprPath = getHome() + "/.nix-defexpr";
|
||||||
globals.instSource.systemFilter = "*";
|
globals.instSource.systemFilter = "*";
|
||||||
|
|
||||||
|
if (!pathExists(globals.instSource.nixExprPath)) {
|
||||||
|
createDirs(globals.instSource.nixExprPath);
|
||||||
|
replaceSymlink(
|
||||||
|
fmt("%s/profiles/per-user/%s/channels", settings.nixStateDir, getUserName()),
|
||||||
|
globals.instSource.nixExprPath + "/channels");
|
||||||
|
if (getuid() != 0)
|
||||||
|
replaceSymlink(
|
||||||
|
fmt("%s/profiles/per-user/root/channels", settings.nixStateDir),
|
||||||
|
globals.instSource.nixExprPath + "/channels_root");
|
||||||
|
}
|
||||||
|
|
||||||
globals.dryRun = false;
|
globals.dryRun = false;
|
||||||
globals.preserveInstalled = false;
|
globals.preserveInstalled = false;
|
||||||
globals.removeAll = false;
|
globals.removeAll = false;
|
||||||
|
|
Loading…
Reference in a new issue