fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . watson ; 8 9iniFormat = pkgs . formats . ini { }; 10 11configDir = if pkgs . stdenv . hostPlatform . isDarwin then 12"Library/Application Support" 13else 14config . xdg . configHome ; 15 16in { 17meta . maintainers = [ maintainers . polykernel ]; 18 19options . programs . watson = { 20enable = mkEnableOption "watson, a wonderful CLI to track your time" ; 21 22package = mkOption { 23type = types . package ; 24default = pkgs . watson ; 25defaultText = literalExpression "pkgs.watson" ; 26description = "Package providing the {command}`watson`." ; 27}; 28 29enableBashIntegration = mkEnableOption "watson's bash integration" // { 30default = true ; 31}; 32 33enableZshIntegration = mkEnableOption "watson's zsh integration" // { 34default = true ; 35}; 36 37enableFishIntegration = mkEnableOption "watson's fish integration" // { 38default = true ; 39}; 40 41settings = mkOption { 42type = iniFormat . type ; 43default = { }; 44description = '' 45Configuration written to 46{file}`$XDG_CONFIG_HOME/watson/config` on Linux or 47{file}`$HOME/Library/Application Support/watson/config` on Darwin. 48 49See <https://github.com/TailorDev/Watson/blob/master/docs/user-guide/configuration.md> 50for an example configuration. 51'' ; 52example = literalExpression '' 53{ 54backend = { 55url = "https://api.crick.fr"; 56token = "yourapitoken"; 57}; 58 59options = { 60stop_on_start = true; 61stop_on_restart = false; 62date_format = "%Y.%m.%d"; 63time_format = "%H:%M:%S%z"; 64week_start = "monday"; 65log_current = false; 66pager = true; 67report_current = false; 68reverse_log = true; 69}; 70} 71'' ; 72}; 73}; 74 75config = mkIf cfg . enable { 76home . packages = [ cfg . package ]; 77 78home . file . " ${ configDir } /watson/config" = mkIf ( cfg . settings != { }) { 79source = iniFormat . generate "watson-config" cfg . settings ; 80}; 81 82programs . bash . initExtra = mkIf cfg . enableBashIntegration '' 83source ${ cfg . package } /share/bash-completion/completions/watson 84'' ; 85 86programs . zsh . initExtra = mkIf cfg . enableZshIntegration '' 87source ${ cfg . package } /share/zsh/site-functions/_watson 88'' ; 89 90programs . fish . shellInit = mkIf cfg . enableFishIntegration '' 91source ${ cfg . package } /share/fish/vendor_completions.d/watson.fish 92'' ; 93}; 94}