Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-open: init at 1.3.0 #24938

Merged
merged 1 commit into from Apr 16, 2017
Merged

git-open: init at 1.3.0 #24938

merged 1 commit into from Apr 16, 2017

Conversation

jlesquembre
Copy link
Member

Motivation for this change

Add git open

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@jlesquembre, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benley, @MarcWeber and @abbradar to be potential reviewers.

@joachifm
Copy link
Contributor

How does git-open capture the in-store git binary?

@@ -0,0 +1,29 @@
{stdenv, git, fetchFromGitHub, ...}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please do not use ... in package expressions; they should normally declare all required params and nothing more.

@jlesquembre
Copy link
Member Author

jlesquembre commented Apr 16, 2017

@joachifm Thanks for your feedback, I updated the PR to remove the .... About your question, git-open doesn't really capture the git binary. In short, when you execute git foo, git looks for git-foo in your PATH and calls it. A better explanation from the official git documentation:

Git subcommands are standalone executables that live in the Git exec path, normally /usr/lib/git-core. The git executable itself is a thin wrapper that knows where the subcommands live, and runs them by passing command-line arguments to them. (If "git foo" is not found in the Git exec path, the wrapper will look in the rest of your $PATH for it. Thus, it’s possible to write local Git extensions that don’t live in system space.)

For even more information:

PD: I also updated git-and-tools/default.nix to keep git-open in alphabetical order

@joachifm
Copy link
Contributor

What I mean is, git-open assumes git is in PATH, which may or may not hold (i.e., it is a runtime impurity). I expected the reason you added git to build inputs was to ensure its availability at runtime.
For optional features i think it's okay to fail at runtime if it's clear to the user how to resolve it, but if it's a basic requirement for the program to work at all it should be patched in/wrapped.

homepage = https://github.com/paulirish/git-open;
description = "Open the GitHub page or website for a repository in your browser";
license = licenses.mit;
platforms = platforms.all;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to maintain this package?

@jlesquembre
Copy link
Member Author

@Mic92 sure, it's a command I use regularly, I'll add myself as maintainer

@joachifm I think now I understand what you mean. You are right, I added git to ensure its availability, but the correct way to do it would be:

  installPhase = ''
    mkdir -p $out/bin
    cp git-open $out/bin
    wrapProgram $out/bin/git-open \
      --prefix PATH ':' "${git}/bin"
  '';

Right? I'm new to NixOS, so if you see room for improvement, corrections are welcome.

@Mic92
Copy link
Member

Mic92 commented Apr 16, 2017

yes, the fix is correct.

@joachifm
Copy link
Contributor

@jlesquembre LGTM. Since this is a bash script, you could patch the source directly to avoid the indirection, but your solution is pretty standard.

I notice that the script also has implicit dependencies on xdg-open and (e)grep. The latter can be safely assumed, but xdg-open may need to be added as well. You can use the makeBinPath helper (from stdenv.lib) for convenience.

@jlesquembre
Copy link
Member Author

@joachifm Thanks again for the feedback, today I learned a lot about nix packages.

I added xdg_tools and gnugrep as dependencies, I hope that I didn't miss anything.

@Mic92 Mic92 merged commit f16b29e into NixOS:master Apr 16, 2017
@Mic92
Copy link
Member

Mic92 commented Apr 16, 2017

Thanks!

@jlesquembre jlesquembre deleted the git-open branch April 25, 2017 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants