summary refs log tree commit diff
path: root/pkgs/development/beam-modules/elvis-erlang/default.nix
blob: c4dda478c4a4e757d98df0fd336f29e1d3abbf1e (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
{ fetchFromGitHub, fetchgit, fetchHex, rebar3WithPlugins, rebar3-nix, rebar3Relx
, buildRebar3, writeScript, lib }:

let
  owner = "inaka";
  repo = "elvis";
in rebar3Relx rec {
  releaseType = "escript";
  # The package name "elvis" is already taken
  pname = "elvis-erlang";
  version = "1.1.0";
  src = fetchFromGitHub {
    inherit owner repo;
    sha256 = "6vNxr3AYpFuXaIVH9bWw7K5KiF1swfI+CSI43RoMQEA=";
    rev = version;
  };
  beamDeps = builtins.attrValues (import ./rebar-deps.nix {
    inherit fetchHex fetchgit fetchFromGitHub;
    builder = buildRebar3;
  });
  passthru.updateScript = writeScript "update.sh" ''
    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p bash common-updater-scripts git nix-prefetch-git gnutar gzip "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}"

    set -euo pipefail

    latest=$(list-git-tags --url=https://github.com/${owner}/${repo}.git | sort -V | tail -1)
    if [ "$latest" != "${version}" ]; then
      nixpkgs="$(git rev-parse --show-toplevel)"
      nix_path="$nixpkgs/pkgs/development/beam-modules/elvis-erlang"
      update-source-version elvis-erlang "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
      tmpdir=$(mktemp -d)
      cp -R $(nix-build $nixpkgs --no-out-link -A elvis-erlang.src)/* "$tmpdir"
      (cd "$tmpdir" && HOME=. rebar3 nix lock -o "$nix_path/rebar-deps.nix")
    else
      echo "${repo} is already up-to-date"
    fi
  '';
  meta = with lib; {
    homepage = "https://github.com/inaka/elvis";
    description = "Erlang Style Reviewer";
    platforms = platforms.unix;
    license = licenses.asl20;
    maintainers = with lib.maintainers; [ dlesl ];
    mainProgram = "elvis";
  };
}