summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/jd/jdenticon-cli/package.nix
blob: bc91523e6f6de3d760d25d0fc403500d28bcda14 (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
{
  lib,
  buildNpmPackage,
  fetchFromGitHub,
  nodejs,
  makeWrapper,
  versionCheckHook,
  nix-update-script,
}:
buildNpmPackage (finalAttrs: {
  pname = "jdenticon-cli";
  version = "3.3.0";
  src = fetchFromGitHub {
    owner = "dmester";
    repo = "jdenticon";
    tag = finalAttrs.version;
    hash = "sha256-uOPNsfEreC7F+Y0WWmudZSPnGxqarna0JPOwQyK6LiQ=";
  };
  npmDepsHash = "sha256-LXwvb088oHmA57EryfYtKi0L/9sB+yyUr/K/qGA1W9k=";

  nativeBuildInputs = [
    makeWrapper
    nodejs
  ];

  installPhase = ''
    runHook preInstall

    install -D bin/jdenticon.js "$out/lib/jdenticon/bin/jdenticon.js"
    install -D dist/jdenticon-node.js "$out/lib/jdenticon/dist/jdenticon-node.js"
    install -d "$out/lib/jdenticon/node_modules"
    cp -r node_modules/canvas-renderer  "$out/lib/jdenticon/node_modules"
    makeWrapper "${lib.getExe nodejs}" "$out/bin/jdenticon" \
      --add-flags "$out/lib/jdenticon/bin/jdenticon.js"

    runHook postInstall
  '';

  doInstallCheck = true;
  nativeInstallCheckInputs = [ versionCheckHook ];

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

  meta = {
    changelog = "https://github.com/dmester/jdenticon/releases/tag/${finalAttrs.version}";
    description = "JavaScript library for generating highly recognizable identicons using HTML5 canvas or SVG.";
    homepage = "https://jdenticon.com/";
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.gipphe ];
    mainProgram = "jdenticon";
  };
})