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 . zathura ; 8 9formatLine = n :v : 10let 11formatValue = v : 12if isBool v then ( if v then "true" else "false" ) else toString v ; 13in ''set ${ n } " ${ formatValue v } "'' ; 14 15formatMapLine = n :v :"map ${ n } ${ toString v } " ; 16 17in { 18meta . maintainers = [ maintainers . rprospero ]; 19 20options . programs . zathura = { 21enable = mkEnableOption '' 22Zathura, a highly customizable and functional document viewer 23focused on keyboard interaction'' ; 24 25package = mkOption { 26type = types . package ; 27default = pkgs . zathura ; 28defaultText = "pkgs.zathura" ; 29description = "The Zathura package to use" ; 30}; 31 32options = mkOption { 33default = { }; 34type = with types ; attrsOf ( either str ( either bool int )); 35description = '' 36Add {option}`:set` command options to zathura and make 37them permanent. See 38{manpage}`zathurarc(5)` 39for the full list of options. 40'' ; 41example = { 42default-bg = "#000000" ; 43default-fg = "#FFFFFF" ; 44}; 45}; 46 47mappings = mkOption { 48default = { }; 49type = with types ; attrsOf str ; 50description = '' 51Add {option}`:map` mappings to zathura and make 52them permanent. See 53{manpage}`zathurarc(5)` 54for the full list of possible mappings. 55 56You can create a mode-specific mapping by specifying the mode before the key: 57`"[normal] <C-b>" = "scroll left";` 58'' ; 59example = { 60D = "toggle_page_mode" ; 61"<Right>" = "navigate next" ; 62"[fullscreen] <C-i>" = "zoom in" ; 63}; 64}; 65 66extraConfig = mkOption { 67type = types . lines ; 68default = "" ; 69description = '' 70Additional commands for zathura that will be added to the 71{file}`zathurarc` file. 72'' ; 73}; 74}; 75 76config = mkIf cfg . enable { 77home . packages = [ cfg . package ]; 78 79xdg . configFile . "zathura/zathurarc" . text = concatStringsSep "\n" ([ ] 80++ optional ( cfg . extraConfig != "" ) cfg . extraConfig 81++ mapAttrsToList formatLine cfg . options 82++ mapAttrsToList formatMapLine cfg . mappings ) + "\n" ; 83}; 84}