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 . ledger ; 8 9cfgText = generators . toKeyValue { 10mkKeyValue = key :value : 11if isBool value then 12optionalString value "-- ${ key } " 13else 14"-- ${ key } ${ toString value } " ; 15listsAsDuplicateKeys = true ; 16} cfg . settings ; 17 18in { 19meta . maintainers = [ ]; 20 21options . programs . ledger = { 22enable = mkEnableOption "ledger, a double-entry accounting system" ; 23 24package = mkPackageOption pkgs "ledger" { }; 25 26settings = mkOption { 27type = with types ; attrsOf ( oneOf [ bool int str ( listOf str ) ]); 28default = { }; 29example = { 30sort = "date" ; 31date-format = "%Y-%m-%d" ; 32strict = true ; 33file = [ 34"~/finances/journal.ledger" 35"~/finances/assets.ledger" 36"~/finances/income.ledger" 37]; 38}; 39description = '' 40Configuration written to {file}`$XDG_CONFIG_HOME/ledger/ledgerrc`. 41See <https://www.ledger-cli.org/3.0/doc/ledger3.html#Detailed-Option-Description> 42for explanation about possible values. 43'' ; 44}; 45 46extraConfig = mkOption { 47type = types . lines ; 48default = "" ; 49example = literalExpression '' 50--sort date 51--effective 52--date-format %Y-%m-%d 53'' ; 54description = '' 55Extra configuration to add to 56{file}`$XDG_CONFIG_HOME/ledger/ledgerrc`. 57'' ; 58}; 59}; 60 61config = mkIf cfg . enable { 62home . packages = [ cfg . package ]; 63 64xdg . configFile . "ledger/ledgerrc" = 65mkIf ( cfg . settings != { } || cfg . extraConfig != "" ) { 66text = cfgText + cfg . extraConfig ; 67}; 68}; 69}