about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/package-management/yarn-lock-converter/default.nix
blob: 70f5b143ebe8bfb6fa3181c9ec8d2fef9fde3985 (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
{ lib
, buildNpmPackage
, fetchurl
, nodejs
, testers
, yarn-lock-converter
}:

let
  source = lib.importJSON ./source.json;
in
buildNpmPackage rec {
  pname = "yarn-lock-converter";
  inherit (source) version;

  src = fetchurl {
    url = "https://registry.npmjs.org/@vht/yarn-lock-converter/-/yarn-lock-converter-${version}.tgz";
    hash = "sha256-CP1wI33fgtp4GSjasktbfWuUjGzCuK3XR+p64aPAryQ=";
  };

  npmDepsHash = source.deps;

  dontBuild = true;

  nativeBuildInputs = [ nodejs ];

  postPatch = ''
    # Use generated package-lock.json as upstream does not provide one
    ln -s ${./package-lock.json} package-lock.json
  '';

  postInstall = ''
    mv $out/bin/@vht/yarn-lock-converter $out/bin/yarn-lock-converter
    rmdir $out/bin/@vht
  '';
  passthru = {
    tests.version = testers.testVersion {
      package = yarn-lock-converter;
    };
    updateScript = ./update.sh;
  };

  meta = with lib; {
    description = "Converts modern Yarn v2+ yarn.lock files into a Yarn v1 format";
    homepage = "https://github.com/VHT/yarn-lock-converter";
    license = licenses.mit;
    maintainers = with maintainers; [ gador ];
    mainProgram = "yarn-lock-converter";
  };
}