1{ lib
2, buildNpmPackage
3, fetchurl
4, nodejs
5, installShellFiles
6, testers
7, node-manta
8}:
9
10let
11 source = lib.importJSON ./source.json;
12in
13buildNpmPackage rec {
14 pname = "manta";
15 inherit (source) version;
16
17 src = fetchurl {
18 url = "https://registry.npmjs.org/${pname}/-/${source.filename}";
19 hash = source.integrity;
20 };
21
22 npmDepsHash = source.deps;
23
24 dontBuild = true;
25
26 nativeBuildInputs = [ nodejs installShellFiles ];
27
28 postPatch = ''
29 # Use generated package-lock.json as upstream does not provide one
30 ln -s ${./package-lock.json} package-lock.json
31 '';
32
33 postInstall = ''
34 ln -s ./lib/node_modules/manta/bin $out/bin
35 '';
36
37 postFixup = ''
38 # create completions, following upstream procedure https://github.com/joyent/node-manta/blob/v5.3.2/Makefile#L85-L91
39 cmds=$(find ./bin/ -type f -printf "%f\n")
40
41 node $out/lib/node_modules/manta/lib/create_client.js
42
43 for cmd in $cmds; do
44 installShellCompletion --cmd $cmd --bash <($out/bin/$cmd --completion)
45
46 # Strip timestamp from generated bash completion
47 sed -i '/Bash completion generated.*/d' $out/share/bash-completion/completions/$cmd.bash
48 done
49 '';
50
51 passthru = {
52 tests.version = testers.testVersion {
53 package = node-manta;
54 };
55 updateScript = ./update.sh;
56 };
57
58 meta = with lib; {
59 description = "Manta Object-Storage Client CLIs and Node.js SDK";
60 homepage = "https://github.com/TritonDataCenter/node-manta";
61 license = licenses.mit;
62 maintainers = with maintainers; [ teutat3s ];
63 mainProgram = "mls";
64 };
65}