mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
parent
5df48c4255
commit
cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions
|
|
@ -1,13 +1,26 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
concatStringsSep literalExpression mapAttrsToList mkIf mkOption types;
|
||||
concatStringsSep
|
||||
literalExpression
|
||||
mapAttrsToList
|
||||
mkIf
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.programs.qutebrowser;
|
||||
|
||||
formatLine = o: n: v:
|
||||
formatLine =
|
||||
o: n: v:
|
||||
let
|
||||
formatValue = v:
|
||||
formatValue =
|
||||
v:
|
||||
if v == null then
|
||||
"None"
|
||||
else if builtins.isBool v then
|
||||
|
|
@ -18,25 +31,32 @@ let
|
|||
"[${concatStringsSep ", " (map formatValue v)}]"
|
||||
else
|
||||
builtins.toString v;
|
||||
in if builtins.isAttrs v then
|
||||
in
|
||||
if builtins.isAttrs v then
|
||||
concatStringsSep "\n" (mapAttrsToList (formatLine "${o}${n}.") v)
|
||||
else
|
||||
"${o}${n} = ${formatValue v}";
|
||||
|
||||
formatDictLine = o: n: v: ''${o}['${n}'] = "${v}"'';
|
||||
formatDictLine =
|
||||
o: n: v:
|
||||
''${o}['${n}'] = "${v}"'';
|
||||
|
||||
formatKeyBindings = m: b:
|
||||
formatKeyBindings =
|
||||
m: b:
|
||||
let
|
||||
formatKeyBinding = m: k: c:
|
||||
formatKeyBinding =
|
||||
m: k: c:
|
||||
if c == null then
|
||||
''config.unbind("${k}", mode="${m}")''
|
||||
else
|
||||
''config.bind("${k}", "${lib.escape [ ''"'' ] c}", mode="${m}")'';
|
||||
in concatStringsSep "\n" (mapAttrsToList (formatKeyBinding m) b);
|
||||
in
|
||||
concatStringsSep "\n" (mapAttrsToList (formatKeyBinding m) b);
|
||||
|
||||
formatQuickmarks = n: s: "${n} ${s}";
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.programs.qutebrowser = {
|
||||
enable = lib.mkEnableOption "qutebrowser";
|
||||
|
||||
|
|
@ -267,51 +287,56 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
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")
|
||||
cfg.keyMappings
|
||||
++ lib.optional (!cfg.enableDefaultBindings) "c.bindings.default = {}"
|
||||
++ mapAttrsToList formatKeyBindings cfg.keyBindings
|
||||
++ lib.optional (cfg.extraConfig != "") cfg.extraConfig);
|
||||
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") cfg.keyMappings
|
||||
++ lib.optional (!cfg.enableDefaultBindings) "c.bindings.default = {}"
|
||||
++ mapAttrsToList formatKeyBindings cfg.keyBindings
|
||||
++ lib.optional (cfg.extraConfig != "") cfg.extraConfig
|
||||
);
|
||||
|
||||
quickmarksFile = lib.optionals (cfg.quickmarks != { }) concatStringsSep "\n"
|
||||
(mapAttrsToList formatQuickmarks cfg.quickmarks);
|
||||
quickmarksFile = lib.optionals (cfg.quickmarks != { }) concatStringsSep "\n" (
|
||||
mapAttrsToList formatQuickmarks cfg.quickmarks
|
||||
);
|
||||
|
||||
greasemonkeyDir =
|
||||
lib.optionals (cfg.greasemonkey != [ ]) pkgs.linkFarmFromDrvs
|
||||
"greasemonkey-userscripts" cfg.greasemonkey;
|
||||
in mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
greasemonkeyDir = lib.optionals (
|
||||
cfg.greasemonkey != [ ]
|
||||
) pkgs.linkFarmFromDrvs "greasemonkey-userscripts" cfg.greasemonkey;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
home.file.".qutebrowser/config.py" =
|
||||
mkIf pkgs.stdenv.hostPlatform.isDarwin { text = qutebrowserConfig; };
|
||||
|
||||
home.file.".qutebrowser/quickmarks" =
|
||||
mkIf (cfg.quickmarks != { } && pkgs.stdenv.hostPlatform.isDarwin) {
|
||||
text = quickmarksFile;
|
||||
home.file.".qutebrowser/config.py" = mkIf pkgs.stdenv.hostPlatform.isDarwin {
|
||||
text = qutebrowserConfig;
|
||||
};
|
||||
|
||||
xdg.configFile."qutebrowser/config.py" =
|
||||
mkIf pkgs.stdenv.hostPlatform.isLinux {
|
||||
home.file.".qutebrowser/quickmarks" =
|
||||
mkIf (cfg.quickmarks != { } && pkgs.stdenv.hostPlatform.isDarwin)
|
||||
{
|
||||
text = quickmarksFile;
|
||||
};
|
||||
|
||||
xdg.configFile."qutebrowser/config.py" = mkIf pkgs.stdenv.hostPlatform.isLinux {
|
||||
text = qutebrowserConfig;
|
||||
onChange = ''
|
||||
hash="$(echo -n "$USER" | md5sum | cut -d' ' -f1)"
|
||||
socket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/qutebrowser/ipc-$hash"
|
||||
if [[ -S $socket ]]; then
|
||||
command=${
|
||||
lib.escapeShellArg (builtins.toJSON {
|
||||
args = [ ":config-source" ];
|
||||
target_arg = null;
|
||||
protocol_version = 1;
|
||||
})
|
||||
lib.escapeShellArg (
|
||||
builtins.toJSON {
|
||||
args = [ ":config-source" ];
|
||||
target_arg = null;
|
||||
protocol_version = 1;
|
||||
}
|
||||
)
|
||||
}
|
||||
echo "$command" | ${pkgs.socat}/bin/socat -lf /dev/null - UNIX-CONNECT:"$socket"
|
||||
fi
|
||||
|
|
@ -319,19 +344,22 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
xdg.configFile."qutebrowser/quickmarks" =
|
||||
mkIf (cfg.quickmarks != { } && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
text = quickmarksFile;
|
||||
};
|
||||
xdg.configFile."qutebrowser/quickmarks" =
|
||||
mkIf (cfg.quickmarks != { } && pkgs.stdenv.hostPlatform.isLinux)
|
||||
{
|
||||
text = quickmarksFile;
|
||||
};
|
||||
|
||||
home.file.".qutebrowser/greasemonkey" =
|
||||
mkIf (cfg.greasemonkey != [ ] && pkgs.stdenv.hostPlatform.isDarwin) {
|
||||
source = greasemonkeyDir;
|
||||
};
|
||||
home.file.".qutebrowser/greasemonkey" =
|
||||
mkIf (cfg.greasemonkey != [ ] && pkgs.stdenv.hostPlatform.isDarwin)
|
||||
{
|
||||
source = greasemonkeyDir;
|
||||
};
|
||||
|
||||
xdg.configFile."qutebrowser/greasemonkey" =
|
||||
mkIf (cfg.greasemonkey != [ ] && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
source = greasemonkeyDir;
|
||||
};
|
||||
};
|
||||
xdg.configFile."qutebrowser/greasemonkey" =
|
||||
mkIf (cfg.greasemonkey != [ ] && pkgs.stdenv.hostPlatform.isLinux)
|
||||
{
|
||||
source = greasemonkeyDir;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue