mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
style: nix fmt
This commit is contained in:
parent
7913481b66
commit
6e0cc170eb
112 changed files with 1977 additions and 1739 deletions
|
|
@ -1,36 +1,45 @@
|
|||
{
|
||||
cfg,
|
||||
config,
|
||||
lib,
|
||||
moduleName,
|
||||
}:
|
||||
with lib; rec {
|
||||
criteriaStr = criteria: let
|
||||
toCriteria = k: v:
|
||||
if builtins.isBool v
|
||||
then
|
||||
(
|
||||
if v
|
||||
then "${k}"
|
||||
else ""
|
||||
)
|
||||
else ''${k}="${v}"'';
|
||||
in "[${concatStringsSep " " (mapAttrsToList toCriteria criteria)}]";
|
||||
|
||||
{ cfg, config, lib, moduleName }:
|
||||
|
||||
with lib;
|
||||
|
||||
rec {
|
||||
criteriaStr = criteria:
|
||||
let
|
||||
toCriteria = k: v:
|
||||
if builtins.isBool v then
|
||||
(if v then "${k}" else "")
|
||||
else
|
||||
''${k}="${v}"'';
|
||||
in "[${concatStringsSep " " (mapAttrsToList toCriteria criteria)}]";
|
||||
|
||||
keybindingDefaultWorkspace = filterAttrs (n: v:
|
||||
keybindingDefaultWorkspace = filterAttrs (_n: v:
|
||||
cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace)
|
||||
cfg.config.keybindings;
|
||||
cfg.config.keybindings;
|
||||
|
||||
keybindingsRest = filterAttrs (n: v:
|
||||
keybindingsRest = filterAttrs (_n: v:
|
||||
cfg.config.defaultWorkspace == null || v != cfg.config.defaultWorkspace)
|
||||
cfg.config.keybindings;
|
||||
cfg.config.keybindings;
|
||||
|
||||
keybindingsStr = { keybindings, bindsymArgs ? "", indent ? "" }:
|
||||
keybindingsStr = {
|
||||
keybindings,
|
||||
bindsymArgs ? "",
|
||||
indent ? "",
|
||||
}:
|
||||
concatStringsSep "\n" (mapAttrsToList (keycomb: action:
|
||||
optionalString (action != null) "${indent}bindsym ${
|
||||
lib.optionalString (bindsymArgs != "") "${bindsymArgs} "
|
||||
}${keycomb} ${action}") keybindings);
|
||||
}${keycomb} ${action}")
|
||||
keybindings);
|
||||
|
||||
keycodebindingsStr = keycodebindings:
|
||||
concatStringsSep "\n" (mapAttrsToList (keycomb: action:
|
||||
optionalString (action != null) "bindcode ${keycomb} ${action}")
|
||||
keycodebindings);
|
||||
keycodebindings);
|
||||
|
||||
colorSetStr = c:
|
||||
concatStringsSep " " [
|
||||
|
|
@ -40,7 +49,7 @@ rec {
|
|||
c.indicator
|
||||
c.childBorder
|
||||
];
|
||||
barColorSetStr = c: concatStringsSep " " [ c.border c.background c.text ];
|
||||
barColorSetStr = c: concatStringsSep " " [c.border c.background c.text];
|
||||
|
||||
modeStr = bindkeysToCode: name: keybindings: ''
|
||||
mode "${name}" {
|
||||
|
|
@ -57,23 +66,42 @@ rec {
|
|||
(map (c: "assign ${criteriaStr c} ${workspace}") criteria);
|
||||
|
||||
fontConfigStr = let
|
||||
toFontStr = { names, style ? "", size ? "" }:
|
||||
optionalString (names != [ ]) concatStringsSep " "
|
||||
(remove "" [ "font" "pango:${concatStringsSep ", " names}" style size ]);
|
||||
in fontCfg:
|
||||
if isList fontCfg then
|
||||
toFontStr { names = fontCfg; }
|
||||
else
|
||||
toFontStr {
|
||||
inherit (fontCfg) names style;
|
||||
size = toString fontCfg.size;
|
||||
};
|
||||
toFontStr = {
|
||||
names,
|
||||
style ? "",
|
||||
size ? "",
|
||||
}:
|
||||
optionalString (names != []) concatStringsSep " "
|
||||
(remove "" ["font" "pango:${concatStringsSep ", " names}" style size]);
|
||||
in
|
||||
fontCfg:
|
||||
if isList fontCfg
|
||||
then toFontStr {names = fontCfg;}
|
||||
else
|
||||
toFontStr {
|
||||
inherit (fontCfg) names style;
|
||||
size = toString fontCfg.size;
|
||||
};
|
||||
|
||||
barStr = { id, fonts, mode, hiddenState, position, workspaceButtons
|
||||
, workspaceNumbers, command, statusCommand, colors, trayOutput, trayPadding
|
||||
, extraConfig, ... }:
|
||||
let colorsNotNull = lib.filterAttrs (n: v: v != null) colors != { };
|
||||
in concatMapStrings (x: x + "\n") (indent (lists.subtractLists [ "" null ]
|
||||
barStr = {
|
||||
id,
|
||||
fonts,
|
||||
mode,
|
||||
hiddenState,
|
||||
position,
|
||||
workspaceButtons,
|
||||
workspaceNumbers,
|
||||
command,
|
||||
statusCommand,
|
||||
colors,
|
||||
trayOutput,
|
||||
trayPadding,
|
||||
extraConfig,
|
||||
...
|
||||
}: let
|
||||
colorsNotNull = lib.filterAttrs (_n: v: v != null) colors != {};
|
||||
in
|
||||
concatMapStrings (x: x + "\n") (indent (lists.subtractLists ["" null]
|
||||
(flatten [
|
||||
"bar {"
|
||||
(optionalString (id != null) "id ${id}")
|
||||
|
|
@ -87,12 +115,12 @@ rec {
|
|||
(optionalString (workspaceButtons != null)
|
||||
"workspace_buttons ${lib.hm.booleans.yesNo workspaceButtons}")
|
||||
(optionalString (workspaceNumbers != null) "strip_workspace_numbers ${
|
||||
lib.hm.booleans.yesNo (!workspaceNumbers)
|
||||
}")
|
||||
lib.hm.booleans.yesNo (!workspaceNumbers)
|
||||
}")
|
||||
(optionalString (trayOutput != null) "tray_output ${trayOutput}")
|
||||
(optionalString (trayPadding != null)
|
||||
"tray_padding ${toString trayPadding}")
|
||||
(optionals colorsNotNull (indent (lists.subtractLists [ "" null ] [
|
||||
(optionals colorsNotNull (indent (lists.subtractLists ["" null] [
|
||||
"colors {"
|
||||
(optionalString (colors.background != null)
|
||||
"background ${colors.background}")
|
||||
|
|
@ -117,13 +145,13 @@ rec {
|
|||
(optionalString (colors.bindingMode != null)
|
||||
"binding_mode ${barColorSetStr colors.bindingMode}")
|
||||
"}"
|
||||
]) { }))
|
||||
]) {}))
|
||||
extraConfig
|
||||
"}"
|
||||
])) { });
|
||||
])) {});
|
||||
|
||||
gapsStr = with cfg.config.gaps;
|
||||
concatStringsSep "\n" (lists.subtractLists [ "" null ] [
|
||||
concatStringsSep "\n" (lists.subtractLists ["" null] [
|
||||
(optionalString (inner != null) "gaps inner ${toString inner}")
|
||||
(optionalString (outer != null) "gaps outer ${toString outer}")
|
||||
(optionalString (horizontal != null)
|
||||
|
|
@ -137,30 +165,41 @@ rec {
|
|||
(optionalString (smartBorders != "off") "smart_borders ${smartBorders}")
|
||||
]);
|
||||
|
||||
windowBorderString = window: floating:
|
||||
let
|
||||
titlebarString = { titlebar, border, ... }:
|
||||
"${if titlebar then "normal" else "pixel"} ${toString border}";
|
||||
in concatStringsSep "\n" [
|
||||
windowBorderString = window: floating: let
|
||||
titlebarString = {
|
||||
titlebar,
|
||||
border,
|
||||
...
|
||||
}: "${
|
||||
if titlebar
|
||||
then "normal"
|
||||
else "pixel"
|
||||
} ${toString border}";
|
||||
in
|
||||
concatStringsSep "\n" [
|
||||
"default_border ${titlebarString window}"
|
||||
"default_floating_border ${titlebarString floating}"
|
||||
];
|
||||
|
||||
floatingCriteriaStr = criteria:
|
||||
"for_window ${criteriaStr criteria} floating enable";
|
||||
windowCommandsStr = { command, criteria, ... }:
|
||||
"for_window ${criteriaStr criteria} ${command}";
|
||||
workspaceOutputStr = item:
|
||||
let outputs = concatMapStringsSep " " strings.escapeNixString item.output;
|
||||
in ''workspace "${item.workspace}" output ${outputs}'';
|
||||
floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable";
|
||||
windowCommandsStr = {
|
||||
command,
|
||||
criteria,
|
||||
...
|
||||
}: "for_window ${criteriaStr criteria} ${command}";
|
||||
workspaceOutputStr = item: let
|
||||
outputs = concatMapStringsSep " " strings.escapeNixString item.output;
|
||||
in ''workspace "${item.workspace}" output ${outputs}'';
|
||||
|
||||
indent = list:
|
||||
{ includesWrapper ? true, level ? 1 }:
|
||||
let prefix = concatStringsSep "" (lib.genList (x: " ") (level * 2));
|
||||
|
||||
in (lib.imap1 (i: v:
|
||||
"${if includesWrapper && (i == 1 || i == (lib.length list)) then
|
||||
v
|
||||
else
|
||||
"${prefix}${v}"}") list);
|
||||
indent = list: {
|
||||
includesWrapper ? true,
|
||||
level ? 1,
|
||||
}: let
|
||||
prefix = concatStringsSep "" (lib.genList (_x: " ") (level * 2));
|
||||
in lib.imap1 (i: v: "${
|
||||
if includesWrapper && (i == 1 || i == (lib.length list))
|
||||
then v
|
||||
else "${prefix}${v}"
|
||||
}")
|
||||
list;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue