Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, anyio
4, buildPythonPackage
5, cargo
6, fetchFromGitHub
7, rustPlatform
8, rustc
9, setuptools-rust
10, pythonOlder
11, dirty-equals
12, pytest-mock
13, pytest-timeout
14, pytestCheckHook
15, python
16, CoreServices
17, libiconv
18}:
19
20buildPythonPackage rec {
21 pname = "watchfiles";
22 version = "0.20.0";
23 format = "pyproject";
24
25 disabled = pythonOlder "3.7";
26
27 src = fetchFromGitHub {
28 owner = "samuelcolvin";
29 repo = pname;
30 rev = "refs/tags/v${version}";
31 hash = "sha256-eoKF6uBHgML63DrDlC1zPfDu/mAMoaevttwqHLCKh+M=";
32 };
33
34 cargoDeps = rustPlatform.fetchCargoTarball {
35 inherit src;
36 name = "${pname}-${version}";
37 hash = "sha256-4XqR6pZqPAftZoJqZf+iZWp0c8xv00MDJDDETiGGEDo=";
38 };
39
40 buildInputs = lib.optionals stdenv.isDarwin [
41 CoreServices
42 libiconv
43 ];
44
45 nativeBuildInputs = [
46 rustPlatform.cargoSetupHook
47 rustPlatform.maturinBuildHook
48 cargo
49 rustc
50 ];
51
52 propagatedBuildInputs = [
53 anyio
54 ];
55
56 # Tests need these permissions in order to use the FSEvents API on macOS.
57 sandboxProfile = ''
58 (allow mach-lookup (global-name "com.apple.FSEvents"))
59 '';
60
61 nativeCheckInputs = [
62 dirty-equals
63 pytest-mock
64 pytest-timeout
65 pytestCheckHook
66 ];
67
68 postPatch = ''
69 sed -i "/^requires-python =.*/a version = '${version}'" pyproject.toml
70 '';
71
72 preCheck = ''
73 rm -rf watchfiles
74 '';
75
76 pythonImportsCheck = [
77 "watchfiles"
78 ];
79
80 meta = with lib; {
81 description = "File watching and code reload";
82 homepage = "https://watchfiles.helpmanual.io/";
83 license = licenses.mit;
84 maintainers = with maintainers; [ fab ];
85 };
86}