mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
feat(hledger): hora standalone
This commit is contained in:
@@ -9,7 +9,10 @@
|
||||
system = "x86_64-darwin";
|
||||
|
||||
nextcloud = "${config.home.homeDirectory}/Nextcloud/ZODIAC";
|
||||
timeLedger = "${nextcloud}/hora.timeclock";
|
||||
|
||||
hora = pkgs.callPackage ../../packages/hora.nix {
|
||||
timeLedger = "${nextcloud}/hora.timeclock";
|
||||
};
|
||||
|
||||
adminEssentials = import ../../configs/admin-essentials.nix {
|
||||
inherit pkgs niveumPackages lib system;
|
||||
@@ -25,53 +28,7 @@
|
||||
in {
|
||||
home.packages =
|
||||
[
|
||||
(pkgs.writers.writeDashBin "hora" ''
|
||||
${pkgs.hledger}/bin/hledger -f "${timeLedger}" "$@"
|
||||
'')
|
||||
(pkgs.writers.writeDashBin "hora-edit" ''
|
||||
nvim + "${timeLedger}"
|
||||
'')
|
||||
(pkgs.writers.writeDashBin "hora-status" ''
|
||||
${pkgs.coreutils}/bin/tac "${timeLedger}" | ${pkgs.gnugrep}/bin/grep -m 1 .
|
||||
'')
|
||||
(pkgs.writers.writeDashBin "hora-start" ''
|
||||
[ -w "${timeLedger}" ] || {
|
||||
echo "${timeLedger}" is not a writable file >/dev/stderr
|
||||
exit 1
|
||||
}
|
||||
last_nonempty_line=$(hora-status)
|
||||
(echo $last_nonempty_line | ${pkgs.gnugrep}/bin/grep -q "^o") || {
|
||||
echo "Last activity must be closed: $last_nonempty_line" >/dev/stderr
|
||||
exit 1
|
||||
}
|
||||
account=$1
|
||||
(hora accounts | ${pkgs.gnugrep}/bin/grep -q "^$account\$") || {
|
||||
echo "The account '$account' is not known. Please add manually."
|
||||
exit 1
|
||||
}
|
||||
|
||||
message=$2
|
||||
date=$(${pkgs.coreutils}/bin/date +"%Y-%m-%d %H:%M:%S")
|
||||
echo "i $date $account $message\n" >> "${timeLedger}"
|
||||
echo Started $account at $date >/dev/stderr
|
||||
'')
|
||||
(pkgs.writers.writeDashBin "hora-stop" ''
|
||||
[ -w "${timeLedger}" ] || {
|
||||
echo "${timeLedger}" is not a writable file >/dev/stderr
|
||||
exit 1
|
||||
}
|
||||
last_nonempty_line=$(hora-status)
|
||||
(echo $last_nonempty_line | ${pkgs.gnugrep}/bin/grep "^i") || {
|
||||
echo "Last activity cannot be closed: $last_nonempty_line" >/dev/stderr
|
||||
exit 1
|
||||
}
|
||||
|
||||
last_activity=$(${pkgs.coreutils}/bin/tail -n 1 ${timeLedger} | ${pkgs.coreutils}/bin/cut -d' ' -f 4)
|
||||
date=$(${pkgs.coreutils}/bin/date +"%Y-%m-%d %H:%M:%S")
|
||||
|
||||
echo "o $date\n" >> ${timeLedger}
|
||||
echo Stopped $last_activity at $date >/dev/stderr
|
||||
'')
|
||||
hora
|
||||
niveumPackages.vim
|
||||
pkgs.ghc
|
||||
pkgs.python3
|
||||
|
||||
Reference in New Issue
Block a user