diff --git a/README.md b/README.md index 6520fd6..f859082 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,9 @@ The following environment variables are optional and can be used to override the ``` NP_DEBUG (1 = debug msgs; 2 = 'set -e' for nix-portable) NP_MINIMAL do not automatically install git +NP_INSTALLGIT force nix-portable to use the installed git. +NP_GITDIR specify the directory containing the git executable. + (The above two are useful in environments with incompalible Git) NP_LOCATION where to put the `.nix-portable` dir. (defaults to `$HOME`) NP_RUNTIME which runtime to use (must be 'bwrap' or 'proot') NP_BWRAP specify the path to the bwrap executable to use diff --git a/default.nix b/default.nix index 47578f2..dfd8a4b 100644 --- a/default.nix +++ b/default.nix @@ -202,8 +202,10 @@ let ### detecting existing git installation - if [ -n "\$NP_MINIMAL" ]; then + if [ -n "\$NP_MINIMAL" ] || [ -n "\$NP_GITDIR" ]; then doInstallGit=false + elif [ -n "\$NP_INSTALLGIT" ]; then + doInstallGit=true else existingGit="\$(PATH="\$PATH_OLD:\$PATH" which git 2>&3)" || existingGit= @@ -454,7 +456,15 @@ let fi # add git if necessary - \$doInstallGit && export PATH="\$PATH:${git.out}/bin" + if \$doInstallGit; then + if [ -n "\$NP_INSTALLGIT" ]; then + export PATH="${git.out}/bin:\$PATH" + else + export PATH="\$PATH:${git.out}/bin" + fi + elif [ -n "\$NP_GITDIR" ]; then + export PATH="\$NP_GITDIR:\$PATH" + fi