From a513fbc395d135d214b30462018262ed346ff755 Mon Sep 17 00:00:00 2001 From: fortune Date: Thu, 29 Apr 2021 02:41:30 +0800 Subject: [PATCH] qutebrowser: fix config location on darwin (#1925) --- modules/programs/qutebrowser.nix | 25 +++++++++++-------- .../programs/qutebrowser/keybindings.nix | 9 +++++-- .../modules/programs/qutebrowser/settings.nix | 9 +++++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/modules/programs/qutebrowser.nix b/modules/programs/qutebrowser.nix index 9521dc2a..cbd6b0eb 100644 --- a/modules/programs/qutebrowser.nix +++ b/modules/programs/qutebrowser.nix @@ -260,16 +260,13 @@ in { }; }; - config = mkIf cfg.enable { - home.packages = [ cfg.package ]; - - xdg.configFile."qutebrowser/config.py".text = concatStringsSep "\n" ([ ] - ++ [ - "${if cfg.loadAutoconfig then - "config.load_autoconfig()" - else - "config.load_autoconfig(False)"}" - ] ++ mapAttrsToList (formatLine "c.") cfg.settings + config = let + qutebrowserConfig = concatStringsSep "\n" ([ + (if cfg.loadAutoconfig then + "config.load_autoconfig()" + else + "config.load_autoconfig(False)") + ] ++ mapAttrsToList (formatLine "c.") cfg.settings ++ mapAttrsToList (formatDictLine "c.aliases") cfg.aliases ++ mapAttrsToList (formatDictLine "c.url.searchengines") cfg.searchEngines ++ mapAttrsToList (formatDictLine "c.bindings.key_mappings") @@ -277,5 +274,13 @@ in { ++ optional (!cfg.enableDefaultBindings) "c.bindings.default = {}" ++ mapAttrsToList formatKeyBindings cfg.keyBindings ++ optional (cfg.extraConfig != "") cfg.extraConfig); + in mkIf cfg.enable { + home.packages = [ cfg.package ]; + + home.file.".qutebrowser/config.py" = + mkIf pkgs.stdenv.hostPlatform.isDarwin { text = qutebrowserConfig; }; + + xdg.configFile."qutebrowser/config.py" = + mkIf pkgs.stdenv.hostPlatform.isLinux { text = qutebrowserConfig; }; }; } diff --git a/tests/modules/programs/qutebrowser/keybindings.nix b/tests/modules/programs/qutebrowser/keybindings.nix index 917bf9ba..1236c058 100644 --- a/tests/modules/programs/qutebrowser/keybindings.nix +++ b/tests/modules/programs/qutebrowser/keybindings.nix @@ -24,9 +24,14 @@ with lib; }) ]; - nmt.script = '' + nmt.script = let + qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then + ".qutebrowser/config.py" + else + ".config/qutebrowser/config.py"; + in '' assertFileContent \ - home-files/.config/qutebrowser/config.py \ + home-files/${qutebrowserConfig} \ ${ pkgs.writeText "qutebrowser-expected-config.py" '' config.load_autoconfig(False) diff --git a/tests/modules/programs/qutebrowser/settings.nix b/tests/modules/programs/qutebrowser/settings.nix index 0eda0171..e9bedcaa 100644 --- a/tests/modules/programs/qutebrowser/settings.nix +++ b/tests/modules/programs/qutebrowser/settings.nix @@ -30,9 +30,14 @@ with lib; }) ]; - nmt.script = '' + nmt.script = let + qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then + ".qutebrowser/config.py" + else + ".config/qutebrowser/config.py"; + in '' assertFileContent \ - home-files/.config/qutebrowser/config.py \ + home-files/${qutebrowserConfig} \ ${ pkgs.writeText "qutebrowser-expected-config.py" '' config.load_autoconfig(False)