2022-03-10 21:52:12 +01:00
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
pkgs,
|
|
|
|
|
...
|
|
|
|
|
}: {
|
2022-05-17 22:34:18 +02:00
|
|
|
environment.systemPackages = let
|
2023-02-24 23:41:01 +01:00
|
|
|
ledgerDirectory = "$HOME/projects/ledger";
|
|
|
|
|
timeLedger = "${ledgerDirectory}/time.timeclock";
|
|
|
|
|
git = "${pkgs.git}/bin/git -C ${ledgerDirectory}";
|
2022-05-17 22:34:18 +02:00
|
|
|
in [
|
2023-02-25 13:23:44 +01:00
|
|
|
pkgs.hledger
|
2022-05-17 22:34:18 +02:00
|
|
|
(pkgs.writers.writeDashBin "hora-edit" ''
|
2022-05-18 18:11:32 +02:00
|
|
|
$EDITOR + "${timeLedger}" && ${pkgs.git}/bin/git -C "$(${pkgs.coreutils}/bin/dirname ${timeLedger})" commit --all --message "$(${pkgs.coreutils}/bin/date -Im)"
|
2022-05-17 22:34:18 +02:00
|
|
|
'')
|
|
|
|
|
(pkgs.writers.writeDashBin "hora" ''
|
|
|
|
|
${pkgs.hledger}/bin/hledger -f "${timeLedger}" "$@"
|
|
|
|
|
'')
|
2022-08-18 18:46:43 +02:00
|
|
|
(pkgs.writers.writeDashBin "hora-filli" ''
|
|
|
|
|
${pkgs.hledger}/bin/hledger -f "${timeLedger}" register fillidefilla -O csv \
|
|
|
|
|
-b "$(date -d "$(date +%Y-%m)-20 last month" +%Y-%m-%d)" \
|
2022-08-19 14:21:57 +02:00
|
|
|
-e "$(date -d "$(date +%Y-%m)-20" +%Y-%m-%d)" \
|
2022-08-18 18:46:43 +02:00
|
|
|
| sed 's/(fillidefilla:\(.*\))/\1/g' \
|
|
|
|
|
| xsv select date,amount,total,account,description
|
|
|
|
|
'')
|
2022-05-17 22:34:18 +02:00
|
|
|
|
2023-02-24 23:41:01 +01:00
|
|
|
(pkgs.writers.writeDashBin "hledger-git" ''
|
|
|
|
|
if [ "$1" = entry ]; then
|
|
|
|
|
${pkgs.hledger}/bin/hledger balance -V > "${ledgerDirectory}/balance.txt"
|
|
|
|
|
${git} add balance.txt
|
|
|
|
|
${git} commit --all --message="$(date -Im)"
|
|
|
|
|
else
|
|
|
|
|
${git} $*
|
|
|
|
|
fi
|
|
|
|
|
'')
|
|
|
|
|
(pkgs.writers.writeDashBin "hledger-edit" ''
|
|
|
|
|
$EDITOR ${ledgerDirectory}/current.journal
|
|
|
|
|
'')
|
|
|
|
|
];
|
2019-04-19 15:02:05 +02:00
|
|
|
}
|