Add wakatime configuration

This commit is contained in:
Tom Willemse 2024-11-22 23:21:15 -08:00
parent 47737fd93c
commit 25d95f3cdd
Signed by: ryuslash
GPG key ID: 7D5C407B435025C1
2 changed files with 92 additions and 2 deletions

View file

@ -97,7 +97,9 @@
home-emacs-pinentry-service-type
home-emacs-vterm-service-type
home-emacs-vterm-configuration
home-emacs-org-modern-service-type))
home-emacs-org-modern-service-type
home-wakatime-service-type
home-wakatime-configuration))
#:use-module ((oni home services environment)
#:select (home-environment-service))
#:use-module ((oni home services flameshot)
@ -416,6 +418,11 @@
(home-emacs-vterm-configuration
(buffer-name-string "*vterm* %s")))
(service home-emacs-org-modern-service-type)
(service home-wakatime-service-type
(home-wakatime-configuration
(api-url "https://waka.ryuslash.org/api")
(exclude '("COMMIT_EDITMSG$"
"TAG_EDITMSG$"))))
(service home-flameshot-service-type)

View file

@ -39,6 +39,12 @@
#:select (emacs-yasnippet-capf
emacs-golden-ratio
emacs-ace-link-notmuch))
#:use-module ((rosenthal packages binaries)
#:select (wakatime-cli-bin))
#:use-module ((rosenthal packages emacs-xyz)
#:select (emacs-wakatime-mode))
#:use-module ((srfi srfi-1)
#:select (every))
#:export (home-emacs-service-type
home-emacs-configuration
@ -71,10 +77,20 @@
home-emacs-vterm-configuration
home-emacs-org-modern-service-type
home-emacs-org-modern-configuration))
home-emacs-org-modern-configuration
home-wakatime-service-type
home-wakatime-configuration))
(define-maybe string)
(define (list-of-strings? obj)
(and (list? obj)
(every string? obj)))
(define (serialize-list-of-strings field value)
(string-append " " (string-join value "\n ")))
;;; Emacs
(define-configuration/no-serialization home-emacs-extension
@ -581,3 +597,70 @@
(compose identity)
(default-value (home-emacs-org-modern-configuration))
(description "Install and configure emacs-org-modern.")))
;;; Wakatime
(define-configuration/no-serialization home-wakatime-configuration
(package
(package wakatime-cli-bin)
"Package to use for the wakatime-cli program")
(emacs-package
(package emacs-wakatime-mode)
"Package to use for setting emacs-wakatime-mode")
(api-url
maybe-string
"URL where the API lives")
;; (api-key
;; maybe-string
;; "API key for connecting to wakatime")
(debug
(boolean #f)
"Run in debug mode?")
(exclude
(list-of-strings '())
"Filename patterns to exclude"))
(define (add-wakatime-emacs-configuration config)
(home-emacs-extension
(configurations
(append
(list (mixed-text-file "wakatime-config"
";;;;; wakatime-config starts here.\n"
;; (if (maybe-value-set? (home-wakatime-configuration-api-key config))
;; (format #f "(setq wakatime-api-key ~s)~%" (home-wakatime-configuration-api-key config))
;; "")
"(setq wakatime-cli-path \"" (home-wakatime-configuration-package config) "/bin/wakatime-cli\")\n"
"(global-wakatime-mode)\n"
";;;;; wakatime-config ends here.\n"))))))
(define (add-wakatime-configuration-file config)
`((".wakatime.cfg"
,(mixed-text-file
"wakatime.cfg"
"[settings]\n"
"api_url = " (home-wakatime-configuration-api-url config) "\n"
"api_key_vault_cmd = secret-tool lookup service wakatime host " (home-wakatime-configuration-api-url config) "\n"
"debug = " (if (home-wakatime-configuration-debug config) "true" "false") "\n"
"exclude =\n"
(serialize-list-of-strings 'exclude (home-wakatime-configuration-exclude config))))))
(define (add-wakatime-packages config)
(list (home-wakatime-configuration-package config)
(home-wakatime-configuration-emacs-package config)))
(define home-wakatime-service-type
(service-type
(name 'home-wakatime)
(extensions
(list (service-extension
home-emacs-service-type
add-wakatime-emacs-configuration)
(service-extension
home-profile-service-type
add-wakatime-packages)
(service-extension
home-files-service-type
add-wakatime-configuration-file)))
(compose identity)
(default-value (home-wakatime-configuration))
(description "Install and configure wakatime.")))