fork/home-manager
git clone https://git.julia.blue/fork/home-manager
8eb8c212
master
1{ config , lib , pkgs , ...} : 2 3let 4 5cfg = config . programs . qcal ; 6 7qcalAccounts = lib . attrValues 8( lib . filterAttrs ( _ :a :a . qcal . enable ) config . accounts . calendar . accounts ); 9 10rename = oldname : 11builtins . getAttr oldname { 12url = "Url" ; 13userName = "Username" ; 14passwordCommand = "PasswordCmd" ; 15}; 16 17filteredAccounts = let 18mkAccount = account : 19lib . filterAttrs ( _ :v :v != null ) ( with account . remote ; { 20Url = url ; 21Username = if userName == null then null else userName ; 22PasswordCmd = 23if passwordCommand == null then null else toString passwordCommand ; 24}); 25in map mkAccount qcalAccounts ; 26 27in { 28meta . maintainers = with lib . maintainers ; [ antonmosich ]; 29 30options = { 31programs . qcal = { 32enable = lib . mkEnableOption "qcal, a CLI calendar application" ; 33 34timezone = lib . mkOption { 35type = lib . types . singleLineStr ; 36default = "Local" ; 37example = "Europe/Vienna" ; 38description = "Timezone to display calendar entries in" ; 39}; 40 41defaultNumDays = lib . mkOption { 42type = lib . types . ints . positive ; 43default = 30 ; 44description = "Default number of days to show calendar entries for" ; 45}; 46}; 47 48accounts . calendar . accounts = lib . mkOption { 49type = with lib . types ; 50attrsOf 51( submodule { options . qcal . enable = lib . mkEnableOption "qcal access" ; }); 52}; 53}; 54 55config = lib . mkIf cfg . enable { 56home . packages = [ pkgs . qcal ]; 57 58xdg . configFile . "qcal/config.json" . source = 59let jsonFormat = pkgs . formats . json { }; 60in jsonFormat . generate "qcal.json" { 61DefaultNumDays = cfg . defaultNumDays ; 62Timezone = cfg . timezone ; 63Calendars = filteredAccounts ; 64}; 65}; 66}