summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/quickjs/default.nix
blob: 1d5726bee259fa9a07185f4edf2b39c1aedc98a3 (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  poetry-core,
  pytestCheckHook,
  pkgs,
}:

let
  inherit (pkgs) quickjs srcOnly;
in

buildPythonPackage rec {
  pname = "quickjs";
  version = "1.19.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "PetterS";
    repo = "quickjs";
    tag = version;
    hash = "sha256-nLloXJWOuaK/enZfwXJI94IcsAMYrkBtG4i3gmxuhfw=";
  };

  patches = [ ./0001-Update-for-QuickJS-2025-04-26-release.patch ];

  # Upstream uses Git submodules; let's de-vendor and use Nix, so that we gain security fixes like
  # https://github.com/NixOS/nixpkgs/pull/407469
  prePatch = ''
    rmdir upstream-quickjs
    ln -s ${srcOnly quickjs} upstream-quickjs
  '';

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail poetry>=1.5.0 poetry \
      --replace-fail poetry poetry-core \
      --replace-fail 'version = "0"' 'version = "${version}"'
  '';

  build-system = [
    poetry-core
    setuptools
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "quickjs" ];

  meta = {
    description = "Python wrapper around the quickjs C library";
    homepage = "https://github.com/PetterS/quickjs";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ philiptaron ];
  };
}