diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 38a4979fa..f8b872056 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1459,6 +1459,13 @@ in
is deployed on a NixOS host.
'';
}
+
+ {
+ time = "2020-04-08T11:51:15+00:00";
+ message = ''
+ A new module is available: 'programs.qutebrowser'
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index e33066c7c..78c67588a 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -94,6 +94,7 @@ let
(loadModule ./programs/password-store.nix { })
(loadModule ./programs/pazi.nix { })
(loadModule ./programs/pidgin.nix { })
+ (loadModule ./programs/qutebrowser.nix { })
(loadModule ./programs/readline.nix { })
(loadModule ./programs/rofi.nix { })
(loadModule ./programs/rtorrent.nix { })
diff --git a/modules/programs/qutebrowser.nix b/modules/programs/qutebrowser.nix
new file mode 100644
index 000000000..da7d44b75
--- /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 config.py file.
+ See
+ 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 config.py 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);
+ };
+}
diff --git a/tests/default.nix b/tests/default.nix
index e71bb3905..493672d71 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -36,6 +36,7 @@ import nmt {
./modules/programs/mbsync
./modules/programs/neomutt
./modules/programs/newsboat
+ ./modules/programs/qutebrowser
./modules/programs/readline
./modules/programs/ssh
./modules/programs/starship
diff --git a/tests/modules/programs/qutebrowser/default.nix b/tests/modules/programs/qutebrowser/default.nix
new file mode 100644
index 000000000..38dcfeff4
--- /dev/null
+++ b/tests/modules/programs/qutebrowser/default.nix
@@ -0,0 +1 @@
+{ qutebrowser-settings = ./settings.nix; }
diff --git a/tests/modules/programs/qutebrowser/settings.nix b/tests/modules/programs/qutebrowser/settings.nix
new file mode 100644
index 000000000..43aef9099
--- /dev/null
+++ b/tests/modules/programs/qutebrowser/settings.nix
@@ -0,0 +1,46 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ programs.qutebrowser = {
+ enable = true;
+
+ settings = {
+ colors = {
+ hints = {
+ bg = "#000000";
+ fg = "#ffffff";
+ };
+ tabs.bar.bg = "#000000";
+ };
+ tabs.tabs_are_windows = true;
+ };
+
+ extraConfig = ''
+ # Extra qutebrowser configuration.
+ '';
+ };
+
+ nixpkgs.overlays = [
+ (self: super: {
+ qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" "";
+ })
+ ];
+
+ nmt.script = ''
+ assertFileContent \
+ home-files/.config/qutebrowser/config.py \
+ ${
+ pkgs.writeText "qutebrowser-expected-config.py" ''
+ c.colors.hints.bg = "#000000"
+ c.colors.hints.fg = "#ffffff"
+ c.colors.tabs.bar.bg = "#000000"
+ c.tabs.tabs_are_windows = True
+ # Extra qutebrowser configuration.
+ ''
+ }
+ '';
+ };
+}