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