about summary refs log tree commit diff
path: root/pkgs/by-name/bq/bqn/package.nix
blob: 5d96a2cbbf9046252eb89d1219f5cc600e62d314 (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
59
60
61
62
{ lib
, stdenvNoCC
, fetchFromGitHub
, makeWrapper
, nodejs
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "bqn";
  version = "0-unstable-2024-05-13";

  src = fetchFromGitHub {
    owner = "mlochbaum";
    repo = "BQN";
    rev = "c971a177421d532a13c4b7515535552df19681e1";
    hash = "sha256-Fru1IIb4IxBQxrEEBoRYStxBqYJJqd+Q+Hwyk++QA68=";
  };

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ nodejs ];

  patches = [
    # Creates a @libbqn@ substitution variable, to be filled in postFixup
    ./001-libbqn-path.patch
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin $out/share/bqn
    cp bqn.js $out/share/bqn/bqn.js
    cp docs/bqn.js $out/share/bqn/libbqn.js

    makeWrapper "${lib.getBin nodejs}/bin/node" "$out/bin/mbqn" \
      --add-flags "$out/share/bqn/bqn.js"

    ln -s $out/bin/mbqn $out/bin/bqn

    runHook postInstall
  '';

  postFixup = ''
    substituteInPlace $out/share/bqn/bqn.js \
      --subst-var-by "libbqn" "$out/share/bqn/libbqn.js"
  '';

  dontConfigure = true;

  dontBuild = true;

  strictDeps = true;

  meta = {
    homepage = "https://github.com/mlochbaum/BQN/";
    description = "Original BQN implementation in Javascript";
    license = lib.licenses.isc;
    maintainers = with lib.maintainers; [ AndersonTorres ];
    inherit (nodejs.meta) platforms;
  };
})
# TODO: install docs and other stuff