1{
2 lib,
3 python3Packages,
4 buildNpmPackage,
5 fetchFromGitHub,
6 stdenv,
7}:
8let
9 src = buildNpmPackage (finalAttrs: {
10 pname = "fava-frontend";
11 version = "1.30.5";
12
13 src = fetchFromGitHub {
14 owner = "beancount";
15 repo = "fava";
16 tag = "v${finalAttrs.version}";
17 hash = "sha256-46ze+1sdgXq9Unhu1ec4buXbH3s/PCcfCx+rmYc+fZw=";
18 };
19 sourceRoot = "${finalAttrs.src.name}/frontend";
20
21 npmDepsHash = "sha256-ImBNqccAd61c9ASzklcooQyh7BYdgJW9DTcQRmFHqho=";
22 makeCacheWritable = true;
23
24 preBuild = ''
25 chmod -R u+w ..
26 '';
27
28 installPhase = ''
29 runHook preInstall
30 cp -R .. $out
31 runHook postInstall
32 '';
33 });
34in
35python3Packages.buildPythonApplication {
36 pname = "fava";
37 version = "1.30.5";
38 pyproject = true;
39
40 inherit src;
41
42 patches = [ ./dont-compile-frontend.patch ];
43
44 postPatch = ''
45 substituteInPlace tests/test_cli.py \
46 --replace-fail '"fava"' '"${placeholder "out"}/bin/fava"'
47 '';
48
49 build-system = [ python3Packages.setuptools-scm ];
50
51 dependencies = with python3Packages; [
52 babel
53 beancount
54 beangulp
55 beanquery
56 cheroot
57 click
58 flask
59 flask-babel
60 jinja2
61 markdown2
62 ply
63 simplejson
64 werkzeug
65 watchfiles
66 ];
67
68 nativeCheckInputs = [ python3Packages.pytestCheckHook ];
69
70 # tests/test_cli.py
71 __darwinAllowLocalNetworking = true;
72
73 # flaky, fails only on ci
74 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [ "tests/test_core_watcher.py" ];
75
76 env = {
77 # Disable some tests when building with beancount2
78 SNAPSHOT_IGNORE = lib.versions.major python3Packages.beancount.version == "2";
79 };
80
81 preCheck = ''
82 export HOME=$TEMPDIR
83 '';
84
85 meta = {
86 description = "Web interface for beancount";
87 mainProgram = "fava";
88 homepage = "https://beancount.github.io/fava";
89 changelog = "https://beancount.github.io/fava/changelog.html";
90 license = lib.licenses.mit;
91 maintainers = with lib.maintainers; [
92 bhipple
93 prince213
94 sigmanificient
95 ];
96 };
97}