DavHau / nix-portable

Nix - Static, Permissionless, Installation-free, Pre-configured
MIT License
870 stars 31 forks source link

Default to using the installed git and add environment variables NP_GIT #28

Closed ShamrockLee closed 2 years ago

ShamrockLee commented 2 years ago

This change make nix-portable install and override git by default, unless users specify the path to git executable with the environment variable NP_GIT.

When nix-portable runs in an environment where the Git version is not compatible (v1.x, etc.), flake-related commands would error out:

$ nix-portable nix flake info
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
error: --- Error ---------------------------------------- nix
program 'git' failed with exit code 129

If applied, the error will be fixed:

$ nix-portable nix flake info
Resolved URL:  git+file:///afs/cern.ch/work/y/yuehshun/private/Projects/DavHau/nix-portable
Locked URL:    git+file:///afs/cern.ch/work/y/yuehshun/private/Projects/DavHau/nix-portable?ref=force-install-git&rev=b517129db9317af9ace7283b14a11a0ef73e2dbd
Path:          /nix/store/j75mrqgbz28kjdc6xms7s5cgh50qbf5x-source
Revision:      b517129db9317af9ace7283b14a11a0ef73e2dbd
Revisions:     52
Last modified: 2022-01-21 03:22:54
ShamrockLee commented 2 years ago

Added some documentation.

DavHau commented 2 years ago

If some git installations cause problems, maybe we should enforce the git installation by default? How about we remove all options NP_MINIMAL, NP_GITDIR, NP_INSTALLGIT. ... And instead have only NP_GIT.

NP_GIT can be:

Only if NP_GIT is specified, the git installation is omitted. In any other case, git from nixpkgs is used.

I think the user experience would be better if there is only one variable to understand. How do you think about this?

ShamrockLee commented 2 years ago

@DavHau Sounds great, but is it okay to add path/to/executable to PATH?

ShamrockLee commented 2 years ago

Done.