biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / office / gnucash / default.nix
blobda94f9674ca28d180ab156b5e22edc785e53b8a7
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchurl
5 , fetchpatch
6 , aqbanking
7 , boost
8 , cmake
9 , gettext
10 , glib
11 , glibcLocales
12 , gtest
13 , guile
14 , gwenhywfar
15 , icu
16 , libdbi
17 , libdbiDrivers
18 , libofx
19 , libxml2
20 , libxslt
21 , makeWrapper
22 , perlPackages
23 , pkg-config
24 , swig
25 , webkitgtk
26 , wrapGAppsHook
29 stdenv.mkDerivation rec {
30   pname = "gnucash";
31   version = "5.6";
33   # raw source code doesn't work out of box; fetchFromGitHub not usable
34   src = fetchurl {
35     url = "https://github.com/Gnucash/gnucash/releases/download/${version}/gnucash-${version}.tar.bz2";
36     hash = "sha256-tLQsYmNQ8+effKHyFzVFzGPd7hrd8kYLGh8iIhvyG9E=";
37   };
39   nativeBuildInputs = [
40     cmake
41     gettext
42     makeWrapper
43     wrapGAppsHook
44     pkg-config
45   ];
47   buildInputs = [
48     aqbanking
49     boost
50     glib
51     glibcLocales
52     gtest
53     guile
54     gwenhywfar
55     icu
56     libdbi
57     libdbiDrivers
58     libofx
59     libxml2
60     libxslt
61     swig
62     webkitgtk
63   ]
64   ++ (with perlPackages; [
65     JSONParse
66     FinanceQuote
67     perl
68   ]);
70   patches = [
71     # this patch disables test-gnc-timezone and test-gnc-datetime which fail due to nix datetime challenges
72     ./0001-disable-date-and-time-tests.patch
73     # this patch prevents the building of gnc-fq-update, a utility which updates the GnuCash cli utils
74     ./0002-disable-gnc-fq-update.patch
75     # this patch prevents the building of gnucash-valgrind
76     ./0003-remove-valgrind.patch
77     # this patch makes gnucash exec the Finance::Quote wrapper directly
78     ./0004-exec-fq-wrapper.patch
79   ];
81   # this needs to be an environment variable and not a cmake flag to suppress
82   # guile warning
83   env.GUILE_AUTO_COMPILE = "0";
85   env.NIX_CFLAGS_COMPILE = toString (lib.optionals (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "12") [
86     # Needed with GCC 12 but breaks on darwin (with clang) or older gcc
87     "-Wno-error=use-after-free"
88   ]);
90   doCheck = true;
91   enableParallelChecking = true;
92   checkTarget = "check";
94   passthru.docs = stdenv.mkDerivation {
95     pname = "gnucash-docs";
96     inherit version;
98     src = fetchFromGitHub {
99       owner = "Gnucash";
100       repo = "gnucash-docs";
101       rev = version;
102       hash = "sha256-rQZoau466Bi/YpPj1XpSsm67FgTYhiMfZfogTtn+m1k=";
103     };
105     nativeBuildInputs = [ cmake ];
106     buildInputs = [ libxml2 libxslt ];
107   };
109   preFixup = ''
110     gappsWrapperArgs+=(
111       # documentation
112       --prefix XDG_DATA_DIRS : ${passthru.docs}/share
113       # db drivers location
114       --set GNC_DBD_DIR ${libdbiDrivers}/lib/dbd
115       # gsettings schema location on Nix
116       --set GSETTINGS_SCHEMA_DIR ${glib.makeSchemaPath "$out" "gnucash-${version}"}
117     )
118   '';
120   # wrapGAppsHook would wrap all binaries including the cli utils which need
121   # Perl wrapping
122   dontWrapGApps = true;
124   # gnucash is wrapped using the args constructed for wrapGAppsHook.
125   # gnc-fq-* are cli utils written in Perl hence the extra wrapping
126   postFixup = ''
127     wrapProgram $out/bin/gnucash "''${gappsWrapperArgs[@]}"
128     wrapProgram $out/bin/gnucash-cli "''${gappsWrapperArgs[@]}"
130     wrapProgram $out/bin/finance-quote-wrapper \
131       --prefix PERL5LIB : "${with perlPackages; makeFullPerlPath [ JSONParse FinanceQuote ]}"
132   '';
134   passthru.updateScript = ./update.sh;
136   meta = with lib; {
137     homepage = "https://www.gnucash.org/";
138     description = "Free software for double entry accounting";
139     longDescription = ''
140       GnuCash is personal and small-business financial-accounting software,
141       freely licensed under the GNU GPL and available for GNU/Linux, BSD,
142       Solaris, Mac OS X and Microsoft Windows.
144       Designed to be easy to use, yet powerful and flexible, GnuCash allows you
145       to track bank accounts, stocks, income and expenses. As quick and
146       intuitive to use as a checkbook register, it is based on professional
147       accounting principles to ensure balanced books and accurate reports.
149       Some interesting features:
151       - Double-Entry Accounting
152       - Stock/Bond/Mutual Fund Accounts
153       - Small-Business Accounting
154       - Reports, Graphs
155       - QIF/OFX/HBCI Import, Transaction Matching
156       - Scheduled Transactions
157       - Financial Calculations
158     '';
159     license = licenses.gpl2Plus;
160     maintainers = with maintainers; [ domenkozar AndersonTorres rski nevivurn ];
161     platforms = platforms.unix;
162     mainProgram = "gnucash";
163   };
165 # TODO: investigate Darwin support