summary refs log tree commit diff
path: root/pkgs/tools/text/ledger2beancount/default.nix
blob: 3852229376769727f469f2a269b2cfedde15d69c (plain) (blame)
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
{ lib, stdenv, fetchFromGitHub, makeWrapper, perlPackages, beancount }:

let
  perlDeps = with perlPackages; [
    DateCalc
    DateTimeFormatStrptime
    enum
    FileBaseDir
    GetoptLongDescriptive
    ListMoreUtils
    RegexpCommon
    StringInterpolate
    YAMLLibYAML
  ];

in stdenv.mkDerivation rec {
  pname = "ledger2beancount";
  version = "2.7";

  src = fetchFromGitHub {
    owner = "beancount";
    repo = "ledger2beancount";
    rev = version;
    sha256 = "sha256-2LIP3ljK1HMAwjk2ueIf9pFL+UUnGDgx9GYNtRztdFY=";
  };

  dontBuild = true;

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [ perlPackages.perl beancount ] ++ perlDeps;

  makeFlags = [ "prefix=$(out)" ];
  installFlags = [ "INSTALL=install" ];

  installPhase = ''
    mkdir -p $out
    cp -r $src/bin $out/bin
  '';

  postFixup = ''
    wrapProgram "$out/bin/ledger2beancount" \
      --set PERL5LIB "${perlPackages.makeFullPerlPath perlDeps}"
  '';

  meta = with lib; {
    description = "Ledger to Beancount text-based converter";
    longDescription = ''
      A script to automatically convert Ledger-based textual ledgers to Beancount ones.

      Conversion is based on (concrete) syntax, so that information that is not meaningful for accounting reasons but still valuable (e.g., comments, formatting, etc.) can be preserved.
    '';
    homepage = "https://github.com/beancount/ledger2beancount";
    license = licenses.gpl3Plus;
    platforms = platforms.all;
    maintainers = with maintainers; [ pablovsky ];
  };
}