summaryrefslogtreecommitdiff
path: root/pkgs/development/lean-modules/proofwidgets/default.nix
blob: 54998125b500067289109f1f1a020eab7f27367b (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
  lib,
  buildLakePackage,
  fetchFromGitHub,
  fetchNpmDeps,
  npmHooks,
  nodejs,
}:

let
  version = "0.0.95";
  src = fetchFromGitHub {
    owner = "leanprover-community";
    repo = "ProofWidgets4";
    tag = "v${version}";
    hash = "sha256-LETljr+QEU6CxprR3pB4hUzhgCD8PrIuiPOgTIdhHVM=";
  };
in

buildLakePackage {
  pname = "lean4-proofwidgets";
  inherit version src;

  leanPackageName = "proofwidgets";

  # ProofWidgets has no Lean dependencies (lake-manifest.json packages = []).
  lakeHash = null;

  nativeBuildInputs = [
    nodejs
    npmHooks.npmConfigHook
  ];

  # Pre-fetched npm dependencies for the TypeScript widget build
  # (npm/rollup in widget/).  npmConfigHook installs these offline.
  npmDeps = fetchNpmDeps {
    name = "lean4-proofwidgets-npm-deps";
    inherit src;
    sourceRoot = "source/widget";
    hash = "sha256-ShH6MDr76wzWQrJvhMWCnklaox/uRsfoe+aYVSo/eNA=";
  };
  npmRoot = "widget";

  # Lake's widgetJsAll target runs `npm clean-install` which wipes
  # node_modules and the patched shebangs that npmConfigHook applied.
  # Wrap npm to skip ci/clean-install (deps already installed) while
  # passing `npm run build` through — same pattern as llama-cpp/evcc.
  postConfigure = ''
    local realNpm
    realNpm="$(type -P npm)"
    mkdir -p "$TMPDIR/npm-wrap"
    cat > "$TMPDIR/npm-wrap/npm" <<WRAPPER
    #!/bin/sh
    case "\$1" in ci|clean-install) exit 0 ;; esac
    exec "$realNpm" "\$@"
    WRAPPER
    chmod +x "$TMPDIR/npm-wrap/npm"
    export PATH="$TMPDIR/npm-wrap:$PATH"
  '';

  meta = {
    description = "Interactive UI framework for Lean 4 proof assistants";
    homepage = "https://github.com/leanprover-community/ProofWidgets4";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ nadja-y ];
  };
}