summary refs log tree commit diff
path: root/pkgs/applications/version-management/git-and-tools/git-subrepo/default.nix
blob: b196d39b46f61cfe1d06692f209238314398c4f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ stdenv, fetchFromGitHub, git, makeWrapper, which }:

stdenv.mkDerivation rec {
  pname = "git-subrepo";
  version = "0.4.0";

  src = fetchFromGitHub {
    owner = "ingydotnet";
    repo = "git-subrepo";
    rev = version;
    sha256 = "05m2dm9gq2nggwnxxdyq2kjj584sn2lxk66pr1qhjxnk81awj9l7";
  };

  nativeBuildInputs = [
    makeWrapper
    which
  ];

  buildInputs = [
    git
  ];

  makeFlags = [
    "PREFIX=${placeholder "out"}"
    "INSTALL_LIB=${placeholder "out"}/bin"
    "INSTALL_MAN=${placeholder "out"}/share/man/man1"
  ];

  patches = [
    # Allow zsh completion to work even though we aren't installing from a git
    # clone.  Also submitted upstream as
    # https://github.com/ingydotnet/git-subrepo/pull/420
    ./zsh-completion.patch
  ];

  postInstall = ''
    ZSH_COMP_DIR="$out/share/zsh/vendor-completions"
    mkdir -p "$ZSH_COMP_DIR"
    cp share/zsh-completion/_git-subrepo "$ZSH_COMP_DIR/"

    BASH_COMP_DIR="$out/share/bash-completion/completions"
    mkdir -p "$BASH_COMP_DIR"
    cp share/completion.bash "$BASH_COMP_DIR/git-subrepo"
  '';

  postFixup = ''
    wrapProgram $out/bin/git-subrepo \
      --prefix PATH : "${git}/bin"
  '';

  meta = with stdenv.lib; {
    homepage = https://github.com/ingydotnet/git-subrepo;
    description = "Git submodule alternative";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = [ maintainers.ryantrinkle ];
  };
}