about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/continuous-integration/woodpecker/common.nix
blob: b8fb8b871c64715ce84888ec83251884534c1f65 (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
{ lib, fetchzip }:
let
  version = "2.3.0";
  srcHash = "sha256-r5TV5WJW2klSlrOG6EjfUgLyHhMI+BMUTY/2JIUgd0Q=";
  # The tarball contains vendored dependencies
  vendorHash = null;
in
{
  inherit version vendorHash;

  src = fetchzip {
    url = "https://github.com/woodpecker-ci/woodpecker/releases/download/v${version}/woodpecker-src.tar.gz";
    hash = srcHash;
    stripRoot = false;
  };

  postInstall = ''
    cd $out/bin
    for f in *; do
      if [ "$f" = cli ]; then
        mv -- "$f" "woodpecker"
        # Issue a warning to the user if they call the deprecated executable
        cat >woodpecker-cli << EOF
    #/bin/sh
    echo 'WARNING: calling `woodpecker-cli` is deprecated, use `woodpecker` instead.' >&2
    $out/bin/woodpecker "\$@"
    EOF
        chmod +x woodpecker-cli
        patchShebangs woodpecker-cli
      else
        mv -- "$f" "woodpecker-$f"
      fi
    done
    cd -
  '';

  ldflags = [
    "-s"
    "-w"
    "-X go.woodpecker-ci.org/woodpecker/v2/version.Version=${version}"
  ];

  meta = with lib; {
    homepage = "https://woodpecker-ci.org/";
    changelog = "https://github.com/woodpecker-ci/woodpecker/blob/v${version}/CHANGELOG.md";
    license = licenses.asl20;
    maintainers = with maintainers; [ ambroisie techknowlogick adamcstephens ];
  };
}