summaryrefslogtreecommitdiff
path: root/pkgs/by-name/co/copybara/package.nix
blob: 9430723fb65a17e13f7f714ce5091f58ca0fa9cb (about) (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
  lib,
  stdenv,
  fetchurl,
  jdk21,
  makeWrapper,
  git,
  gnused,
  gnugrep,
  gawk,
  which,
  nix-update-script,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "copybara";
  version = "20250728";

  src = fetchurl {
    url = "https://github.com/google/copybara/releases/download/v${finalAttrs.version}/copybara_deploy.jar";
    hash = "sha256-/ulX5Q+P6ViiDcdwRpd9zhJAQiFULzU2fSXvfOk36xo=";
  };

  nativeBuildInputs = [
    makeWrapper
  ];

  buildInputs = [
    jdk21
  ];

  runtimeDeps = [
    git
    gnused
    gnugrep
    gawk
    which
  ];

  dontUnpack = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/java
    cp $src $out/share/java/copybara.jar

    mkdir -p $out/bin
    makeWrapper ${jdk21}/bin/java $out/bin/copybara \
      --add-flags "-jar $out/share/java/copybara.jar" \
      --prefix PATH : ${lib.makeBinPath finalAttrs.runtimeDeps}

    runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Tool for transforming and moving code between repositories";
    longDescription = ''
      Copybara is a tool used internally at Google for transforming and moving
      code between repositories. It allows you to maintain code in multiple
      repositories while keeping them in sync through transformations.

      Common use cases include:
      - Importing sections of code from a confidential repository to a public repository
      - Importing code from a public repository to a confidential repository
      - Moving changes between authoritative and non-authoritative repositories
    '';
    homepage = "https://github.com/google/copybara";
    changelog = "https://github.com/google/copybara/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ cameroncuttingedge ];
    platforms = lib.platforms.all;
    mainProgram = "copybara";
    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
  };
})