diff options
author | Justin Lovinger <git@justinlovinger.com> | 2020-04-07 03:10:07 -0400 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2020-04-08 14:50:59 +0200 |
commit | b7737f17322e648a7739529c4728b99b4b65ff5b (patch) | |
tree | 2b5b19ad93f2ba91f5e4226ff1a2144a9e4fea6c /modules/programs/qutebrowser.nix | |
parent | d06bcf4c970e45fa260e992d96160b48712504e6 (diff) |
qutebrowser: add module
PR #1132
Diffstat (limited to 'modules/programs/qutebrowser.nix')
-rw-r--r-- | modules/programs/qutebrowser.nix | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/modules/programs/qutebrowser.nix b/modules/programs/qutebrowser.nix new file mode 100644 index 00000000000..da7d44b758e --- /dev/null +++ b/modules/programs/qutebrowser.nix @@ -0,0 +1,67 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.qutebrowser; + + formatLine = o: n: v: + let + formatValue = v: + if builtins.isNull v then + "None" + else if builtins.isBool v then + (if v then "True" else "False") + else if builtins.isString v then + ''"${v}"'' + else + builtins.toString v; + in if builtins.isAttrs v then + concatStringsSep "\n" (mapAttrsToList (formatLine "${o}${n}.") v) + else + "${o}${n} = ${formatValue v}"; + +in { + options.programs.qutebrowser = { + enable = mkEnableOption "qutebrowser"; + + settings = mkOption { + type = types.attrs; + default = { }; + description = '' + Options to add to qutebrowser <filename>config.py</filename> file. + See <link xlink:href="https://qutebrowser.org/doc/help/settings.html"/> + for options. + ''; + example = literalExample '' + { + colors = { + hints = { + bg = "#000000"; + fg = "#ffffff"; + }; + tabs.bar.bg = "#000000"; + }; + tabs.tabs_are_windows = true; + } + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra lines added to qutebrowser <filename>config.py</filename> file. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.qutebrowser ]; + + xdg.configFile."qutebrowser/config.py".text = concatStringsSep "\n" ([ ] + ++ mapAttrsToList (formatLine "c.") cfg.settings + ++ optional (cfg.extraConfig != "") cfg.extraConfig); + }; +} |