nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildNpmPackage,
4 fetchFromGitHub,
5 nodejs,
6 faketty,
7 openssl,
8 prisma,
9 prisma-engines,
10}:
11
12buildNpmPackage rec {
13 pname = "ghostfolio";
14 version = "2.185.0";
15
16 src = fetchFromGitHub {
17 owner = "ghostfolio";
18 repo = "ghostfolio";
19 tag = version;
20 hash = "sha256-jnC2u9ZZcOSux6UUzW9Ot02aFWeGYhrdCC9d4xM0efA=";
21 # populate values that require us to use git. By doing this in postFetch we
22 # can delete .git afterwards and maintain better reproducibility of the src.
23 leaveDotGit = true;
24 postFetch = ''
25 date -u -d "@$(git -C $out log -1 --pretty=%ct)" +%s%3N > $out/SOURCE_DATE_EPOCH
26 find "$out" -name .git -print0 | xargs -0 rm -rf
27 '';
28 };
29
30 npmDepsHash = "sha256-FCH0v9jRviH33mfIVX8967X1u494qToHraYVn5pbSPw=";
31
32 nativeBuildInputs = [
33 prisma
34 faketty
35 ];
36
37 # Disallow cypress from downloading binaries in sandbox
38 env.CYPRESS_INSTALL_BINARY = "0";
39
40 buildPhase = ''
41 runHook preBuild
42
43 prisma generate
44
45 substituteInPlace replace.build.mjs \
46 --replace-fail 'new Date()' "new Date(''$(<SOURCE_DATE_EPOCH))"
47
48 # Workaround for https://github.com/nrwl/nx/issues/22445
49 faketty npm run build:production
50
51 cp -r node_modules dist/apps/api/
52 cp -r prisma dist/apps/api/
53
54 runHook postBuild
55 '';
56
57 installPhase = ''
58 runHook preInstall
59
60 mkdir -p "$out/lib/node_modules/ghostfolio"
61 cp -r dist/apps/{api,client} "$out/lib/node_modules/ghostfolio/"
62
63 mkdir "$out/bin"
64 makeWrapper ${lib.getExe nodejs} "$out/bin/ghostfolio" \
65 --add-flags "$out/lib/node_modules/ghostfolio/api/main" "''${user_args[@]}" \
66 --prefix PATH : ${lib.makeBinPath [ openssl ]} \
67 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl ]} \
68 ${lib.concatStringsSep " " (
69 lib.mapAttrsToList (name: value: "--set ${name} ${lib.escapeShellArg value}") {
70 PRISMA_SCHEMA_ENGINE_BINARY = lib.getExe' prisma-engines "schema-engine";
71 PRISMA_QUERY_ENGINE_BINARY = lib.getExe' prisma-engines "query-engine";
72 PRISMA_QUERY_ENGINE_LIBRARY = "${prisma-engines}/lib/libquery_engine.node";
73 PRISMA_INTROSPECTION_ENGINE_BINARY = lib.getExe' prisma-engines "introspection-engine";
74 PRISMA_FMT_BINARY = lib.getExe' prisma-engines "prisma-fmt";
75 }
76 )}
77
78 runHook postInstall
79 '';
80
81 meta = {
82 description = "Open Source Wealth Management Software";
83 homepage = "https://github.com/ghostfolio/ghostfolio";
84 changelog = "https://github.com/ghostfolio/ghostfolio/blob/${src.rev}/CHANGELOG.md";
85 license = lib.licenses.agpl3Only;
86 maintainers = with lib.maintainers; [ moraxyc ];
87 mainProgram = "ghostfolio";
88 };
89}