diff mbox

[2/3] gnu: Add ledger.

Message ID 1463023686.3455318.605409553.05451A73@webmail.messagingengine.com
State New
Headers show

Commit Message

Alex Griffin May 12, 2016, 3:28 a.m. UTC
Here's an updated patch with the suggested changes. I also re-enabled
the shared library and python module, and built html docs, and a few
other things. This turned out to be a much more challenging package than
I expected! Hopefully it is finally finished or very close to finished.

Thanks,

Comments

Alex Kost May 12, 2016, 9:12 a.m. UTC | #1
Alex Griffin (2016-05-12 06:28 +0300) wrote:

> Here's an updated patch with the suggested changes. I also re-enabled
> the shared library and python module, and built html docs, and a few
> other things. This turned out to be a much more challenging package than
> I expected! Hopefully it is finally finished or very close to finished.

Hello, was this package built successfully for you?  I tried it but the
build phase failed (I'm attaching the last part of the build process [1]
just in case).  I don't know, maybe I just don't have enough memory
(3GB) to build it (I had such problems with cmake before).

> From e6fb89828f44765d36a658bd2b497aa8bd8b12d9 Mon Sep 17 00:00:00 2001
> From: Alex Griffin <a@ajgrf.com>
> Date: Sat, 7 May 2016 12:20:47 -0500
> Subject: [PATCH 2/2] gnu: Add ledger.
>
> * gnu/packages/finance.scm (ledger): New variable.
[...]
> +(define-public ledger
> +  (package
> +    (name "ledger")
> +    (version "3.1.1")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append "https://github.com/ledger/ledger/archive/v"
> +                                  version
> +                                  ".tar.gz"))
> +              (file-name (string-append name "-" version ".tar.gz"))
> +              (sha256
> +               (base32
> +                "12jlv3gsjhrja25q9hrwh73cdacd2l3c2yyn8qnijav9mdhnbw4h"))))
> +    (build-system cmake-build-system)
> +    (arguments
> +     `(#:phases
> +       (let* ((out (assoc-ref %outputs "out"))
> +              (examples (string-append out "/share/doc/ledger/examples"))
> +              (site-lisp (string-append out "/share/emacs/site-lisp")))
> +         (modify-phases %standard-phases
> +           (add-before 'configure 'install-examples
> +             (lambda _
> +               (install-file "test/input/sample.dat" examples)
> +               (install-file "test/input/demo.ledger" examples)))

Every phase should return non-false value if it succeeded.  So since the
returned value of 'install-file' is not specified, we add #t to the end
of such phases.  Please add #t to all phases except the following
(build-doc) because zero? returns #t if succeeded.

> +           (add-after 'build 'build-doc
> +             (lambda _ (zero? (system* "make" "doc"))))
> +           (add-before 'check 'check-setup
> +             ;; one test fails if it can't set the timezone
> +             (lambda _ (setenv "TZDIR"
> +                               (string-append (assoc-ref %build-inputs "tzdata")
> +                                              "/share/zoneinfo"))))

Unlike configure-flags where we can use only %build-inputs, in phases,
it is better to use a functional style using 'inputs' passed to a phase
as argument:

             (lambda* (#:key inputs #:allow-other-keys)
               (setenv "TZDIR"
                       (string-append (assoc-ref inputs "tzdata")
                                      "/share/zoneinfo"))
               #t)

> +           (add-after 'install 'relocate-elisp
> +             (lambda _
> +               (mkdir-p (string-append site-lisp "/guix.d"))
> +               (rename-file (string-append site-lisp "/ledger-mode")
> +                            (string-append site-lisp "/guix.d/ledger-mode"))))))

(Sorry, the following comment is not related to this patch)

This is another point for us to get rid of "guix.d" part: it is a common
practice for packages to put elisp files in a sub-directory of
"share/emacs/site-lisp/" (at least mu, magit and git-modes do this as
well).

It seems natural for me if our emacs will look in "site-lisp/<package>"
instead of "site-lisp/guix.d/<package>", so there will be no need to
adjust such packages to move elisp files.

So I beg people to answer to
<http://lists.gnu.org/archive/html/guix-devel/2016-05/msg00296.html>.
"guix.d" part is a redundant level in file hierarchy, let's remove it!

> +       #:configure-flags
> +       `("-DBUILD_DOCS:BOOL=ON"
> +         "-DBUILD_WEB_DOCS:BOOL=ON"
> +         "-DBUILD_EMACSLISP:BOOL=ON"
> +         "-DUSE_PYTHON:BOOL=ON"
> +         "-DCMAKE_INSTALL_LIBDIR:PATH=lib"
> +         ,(string-append "-DUTFCPP_INCLUDE_DIR:PATH="
> +                         (assoc-ref %build-inputs "utfcpp")
> +                         "/include"))))

It doesn't matter but usually we put #:configure-flags before #:phases.
diff mbox

Patch

From e6fb89828f44765d36a658bd2b497aa8bd8b12d9 Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
Date: Sat, 7 May 2016 12:20:47 -0500
Subject: [PATCH 2/2] gnu: Add ledger.

* gnu/packages/finance.scm (ledger): New variable.
---
 gnu/packages/finance.scm | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index e9487d4..c19e2ca 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -1,6 +1,7 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,13 +24,21 @@ 
  #:use-module (guix download)
  #:use-module (guix build utils)
  #:use-module (guix build-system gnu)
+ #:use-module (guix build-system cmake)
+ #:use-module (gnu packages base)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages databases)
+ #:use-module (gnu packages emacs)
+ #:use-module (gnu packages groff)
+ #:use-module (gnu packages libedit)
  #:use-module (gnu packages linux)
+ #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages protobuf)
  #:use-module (gnu packages python)
  #:use-module (gnu packages qt)
+ #:use-module (gnu packages texinfo)
+ #:use-module (gnu packages textutils)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages upnp))
 
@@ -81,3 +90,85 @@  collectively by the network.  Bitcoin Core is the reference implementation
 of the bitcoin protocol.  This package provides the Bitcoin Core command
 line client and a client based on Qt.")
     (license license:expat)))
+
+(define-public ledger
+  (package
+    (name "ledger")
+    (version "3.1.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/ledger/ledger/archive/v"
+                                  version
+                                  ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "12jlv3gsjhrja25q9hrwh73cdacd2l3c2yyn8qnijav9mdhnbw4h"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:phases
+       (let* ((out (assoc-ref %outputs "out"))
+              (examples (string-append out "/share/doc/ledger/examples"))
+              (site-lisp (string-append out "/share/emacs/site-lisp")))
+         (modify-phases %standard-phases
+           (add-before 'configure 'install-examples
+             (lambda _
+               (install-file "test/input/sample.dat" examples)
+               (install-file "test/input/demo.ledger" examples)))
+           (add-after 'build 'build-doc
+             (lambda _ (zero? (system* "make" "doc"))))
+           (add-before 'check 'check-setup
+             ;; one test fails if it can't set the timezone
+             (lambda _ (setenv "TZDIR"
+                               (string-append (assoc-ref %build-inputs "tzdata")
+                                              "/share/zoneinfo"))))
+           (add-after 'install 'relocate-elisp
+             (lambda _
+               (mkdir-p (string-append site-lisp "/guix.d"))
+               (rename-file (string-append site-lisp "/ledger-mode")
+                            (string-append site-lisp "/guix.d/ledger-mode"))))))
+       #:configure-flags
+       `("-DBUILD_DOCS:BOOL=ON"
+         "-DBUILD_WEB_DOCS:BOOL=ON"
+         "-DBUILD_EMACSLISP:BOOL=ON"
+         "-DUSE_PYTHON:BOOL=ON"
+         "-DCMAKE_INSTALL_LIBDIR:PATH=lib"
+         ,(string-append "-DUTFCPP_INCLUDE_DIR:PATH="
+                         (assoc-ref %build-inputs "utfcpp")
+                         "/include"))))
+    (inputs `(("boost" ,boost)
+              ("gmp" ,gmp)
+              ("libedit" ,libedit)
+              ("mpfr" ,mpfr)
+              ("python" ,python-2)
+              ("tzdata" ,tzdata)
+              ("utfcpp" ,utfcpp)))
+    (native-inputs `(("emacs-no-x" ,emacs-no-x)
+                     ("groff" ,groff)
+                     ("texinfo" ,texinfo)))
+    (home-page "http://ledger-cli.org/")
+    (synopsis "Command-line double-entry accounting program")
+    (description
+     "Ledger is a powerful, double-entry accounting system that is
+accessed from the UNIX command-line.  This may put off some users, since
+there is no flashy UI, but for those who want unparalleled reporting
+access to their data there are few alternatives.
+
+Ledger uses text files for input.  It reads the files and generates
+reports; there is no other database or stored state.  To use Ledger,
+you create a file of your account names and transactions, run from the
+command line with some options to specify input and requested reports, and
+get output.  The output is generally plain text, though you could generate
+a graph or html instead.  Ledger is simple in concept, surprisingly rich
+in ability, and easy to use.")
+    ;; There are some extra licenses in files which do not presently get
+    ;; installed when you build this package.  Different versions of the GPL
+    ;; are used in the contrib and python subdirectories.  The bundled version
+    ;; of utfcpp is under the Boost 1.0 license. Also the file
+    ;; `tools/update_copyright_year` has an Expat license.
+    (license (list license:bsd-3
+                   license:asl2.0     ; src/strptime.cc
+                   (license:non-copyleft
+                    "file://src/wcwidth.cc"
+                    "See src/wcwidth.cc in the distribution.")
+                   license:gpl2+))))  ; lisp/*
-- 
2.7.4