1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 poetry-core,
7 pytestCheckHook,
8 pkgs,
9}:
10
11let
12 inherit (pkgs) quickjs srcOnly;
13in
14
15buildPythonPackage rec {
16 pname = "quickjs";
17 version = "1.19.4";
18 pyproject = true;
19
20 src = fetchFromGitHub {
21 owner = "PetterS";
22 repo = "quickjs";
23 tag = version;
24 hash = "sha256-nLloXJWOuaK/enZfwXJI94IcsAMYrkBtG4i3gmxuhfw=";
25 };
26
27 patches = [ ./0001-Update-for-QuickJS-2025-04-26-release.patch ];
28
29 # Upstream uses Git submodules; let's de-vendor and use Nix, so that we gain security fixes like
30 # https://github.com/NixOS/nixpkgs/pull/407469
31 prePatch = ''
32 rmdir upstream-quickjs
33 ln -s ${srcOnly quickjs} upstream-quickjs
34 '';
35
36 postPatch = ''
37 substituteInPlace pyproject.toml \
38 --replace-fail poetry>=1.5.0 poetry \
39 --replace-fail poetry poetry-core \
40 --replace-fail 'version = "0"' 'version = "${version}"'
41 '';
42
43 build-system = [
44 poetry-core
45 setuptools
46 ];
47
48 nativeCheckInputs = [ pytestCheckHook ];
49
50 pythonImportsCheck = [ "quickjs" ];
51
52 meta = {
53 description = "Python wrapper around the quickjs C library";
54 homepage = "https://github.com/PetterS/quickjs";
55 license = lib.licenses.mit;
56 maintainers = with lib.maintainers; [ philiptaron ];
57 };
58}