about summary refs log tree commit diff
path: root/pkgs/development/tools/yarn/default.nix
blob: 9d95676ec2cea1361cea54e42ae01f92b3b01be6 (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
{ lib
, fetchFromGitHub
, fetchzip
, nodejs
, stdenvNoCC
, testers
, gitUpdater
, withNode ? true
}:

let
  completion = fetchFromGitHub {
    owner = "dsifford";
    repo = "yarn-completion";
    rev = "v0.17.0";
    hash = "sha256-z7KPXeYPPRuaEPxgY6YqsLt9n8cSsW3n2FhOzVde1HU=";
  };
in
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "yarn";
  version = "1.22.22";

  src = fetchzip {
    url = "https://github.com/yarnpkg/yarn/releases/download/v${finalAttrs.version}/yarn-v${finalAttrs.version}.tar.gz";
    sha256 = "sha256-kFa+kmnBerTB7fY/IvfAFy/4LWvrl9lrRHMOUdOZ+Wg=";
  };

  buildInputs = lib.optionals withNode [ nodejs ];

  installPhase = ''
    mkdir -p $out/{bin,libexec/yarn/,share/bash-completion/completions/}
    cp -R . $out/libexec/yarn
    ln -s $out/libexec/yarn/bin/yarn.js $out/bin/yarn
    ln -s $out/libexec/yarn/bin/yarn.js $out/bin/yarnpkg
    ln -s ${completion}/yarn-completion.bash $out/share/bash-completion/completions/yarn.bash
  '';

  passthru = {
    tests.version = lib.optionalAttrs withNode (testers.testVersion {
      package = finalAttrs.finalPackage;
    });

    updateScript = gitUpdater {
      url = "https://github.com/yarnpkg/yarn.git";
      rev-prefix = "v";
    };
  };

  meta = with lib; {
    description = "Fast, reliable, and secure dependency management for javascript";
    homepage = "https://classic.yarnpkg.com/";
    changelog = "https://github.com/yarnpkg/yarn/blob/v${finalAttrs.version}/CHANGELOG.md";
    license = licenses.bsd2;
    maintainers = with maintainers; [ offline screendriver marsam ];
    platforms = platforms.all;
    mainProgram = "yarn";
  };
})