btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / no / node-hp-scan-to / package.nix
blob86498d2b7fd52c51dcf7ca1c3120e0f8d28deb18
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchYarnDeps
5 , makeWrapper
6 , nodejs
7 , fixup-yarn-lock
8 , yarn
9 }:
11 stdenv.mkDerivation (finalAttrs: {
12   pname = "node-hp-scan-to";
13   version = "1.4.3";
15   src = fetchFromGitHub {
16     owner = "manuc66";
17     repo = "node-hp-scan-to";
18     rev = "v${finalAttrs.version}";
19     hash = "sha256-/XUqCL2F1iMYUoCbGgL9YKs+8wIFHvmh2O0LMbDU8yE=";
20   };
22   offlineCache = fetchYarnDeps {
23     yarnLock = "${finalAttrs.src}/yarn.lock";
24     hash = "sha256-pxeYumHuomOFyCi8XhYTYQNcsGOUvjOg36bFD0yhdLk=";
25   };
27   nativeBuildInputs = [
28     makeWrapper
29     nodejs
30     fixup-yarn-lock
31     yarn
32   ];
34   configurePhase = ''
35     runHook preConfigure
37     export HOME=$(mktemp -d)
38     yarn config --offline set yarn-offline-mirror $offlineCache
39     fixup-yarn-lock yarn.lock
40     yarn --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive install
41     patchShebangs node_modules
43     runHook postConfigure
44   '';
46   buildPhase = ''
47     runHook preBuild
49     yarn --offline build
51     runHook postBuild
52   '';
54   installPhase = ''
55     runHook preInstall
57     yarn --offline --production install
59     mkdir -p "$out/lib/node_modules/node-hp-scan-to"
60     cp -r dist node_modules package.json "$out/lib/node_modules/node-hp-scan-to"
62     makeWrapper "${nodejs}/bin/node" "$out/bin/node-hp-scan-to" \
63       --add-flags "$out/lib/node_modules/node-hp-scan-to/dist/index.js"
65     runHook postInstall
66   '';
68   meta = {
69     changelog = "https://github.com/manuc66/node-hp-scan-to/releases/tag/${finalAttrs.src.rev}";
70     description = "Allow to send scan from device to computer for some HP All-in-One Printers";
71     homepage = "https://github.com/manuc66/node-hp-scan-to";
72     license = lib.licenses.mit;
73     mainProgram = "node-hp-scan-to";
74     maintainers = with lib.maintainers; [ jonas-w ];
75   };