mirror of
https://github.com/nix-community/home-manager
synced 2024-11-22 12:43:14 +00:00
parent
55779b20cd
commit
f911ebbec9
17 changed files with 51 additions and 56 deletions
5
modules/lib/booleans.nix
Normal file
5
modules/lib/booleans.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{ lib }: {
|
||||
# Converts a boolean to a yes/no string. This is used in lots of
|
||||
# configuration formats.
|
||||
yesNo = value: if value then "yes" else "no";
|
||||
}
|
|
@ -18,6 +18,7 @@ rec {
|
|||
|
||||
assertions = import ./assertions.nix { inherit lib; };
|
||||
|
||||
booleans = import ./booleans.nix { inherit lib; };
|
||||
gvariant = import ./gvariant.nix { inherit lib; };
|
||||
maintainers = import ./maintainers.nix;
|
||||
strings = import ./strings.nix { inherit lib; };
|
||||
|
|
|
@ -6,7 +6,6 @@ let
|
|||
|
||||
cfg = config.programs.irssi;
|
||||
|
||||
boolStr = b: if b then "yes" else "no";
|
||||
quoteStr = s: escape [ ''"'' ] s;
|
||||
|
||||
# Comma followed by newline.
|
||||
|
@ -33,9 +32,9 @@ let
|
|||
chatnet = "${k}";
|
||||
address = "${v.server.address}";
|
||||
port = "${toString v.server.port}";
|
||||
use_ssl = "${boolStr v.server.ssl.enable}";
|
||||
ssl_verify = "${boolStr v.server.ssl.verify}";
|
||||
autoconnect = "${boolStr v.server.autoConnect}";
|
||||
use_ssl = "${lib.hm.booleans.yesNo v.server.ssl.enable}";
|
||||
ssl_verify = "${lib.hm.booleans.yesNo v.server.ssl.verify}";
|
||||
autoconnect = "${lib.hm.booleans.yesNo v.server.autoConnect}";
|
||||
${
|
||||
lib.optionalString (v.server.ssl.certificateFile != null) ''
|
||||
ssl_cert = "${v.server.ssl.certificateFile}";
|
||||
|
@ -50,7 +49,7 @@ let
|
|||
{
|
||||
chatnet = "${k}";
|
||||
name = "${c}";
|
||||
autojoin = "${boolStr cv.autoJoin}";
|
||||
autojoin = "${lib.hm.booleans.yesNo cv.autoJoin}";
|
||||
}
|
||||
'')))));
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@ let
|
|||
toKittyConfig = generators.toKeyValue {
|
||||
mkKeyValue = key: value:
|
||||
let
|
||||
value' = if isBool value then
|
||||
(if value then "yes" else "no")
|
||||
else
|
||||
toString value;
|
||||
value' =
|
||||
(if isBool value then lib.hm.booleans.yesNo else toString) value;
|
||||
in "${key} ${value'}";
|
||||
};
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ let
|
|||
if isList v then
|
||||
concatMapStringsSep " " (genValue n) v
|
||||
else if isBool v then
|
||||
(if v then "yes" else "no")
|
||||
lib.hm.booleans.yesNo v
|
||||
else if isInt v then
|
||||
toString v
|
||||
else if isString v && hasSpace v then
|
||||
|
|
|
@ -18,9 +18,7 @@ let
|
|||
rec {
|
||||
int = toString option;
|
||||
float = int;
|
||||
|
||||
bool = if option then "yes" else "no";
|
||||
|
||||
bool = lib.hm.booleans.yesNo option;
|
||||
string = option;
|
||||
}.${typeOf option};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ let
|
|||
renderValue = option:
|
||||
{
|
||||
int = toString option;
|
||||
bool = if option then "yes" else "no";
|
||||
bool = lib.hm.booleans.yesNo option;
|
||||
string = option;
|
||||
}.${builtins.typeOf option};
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
yesno = x: if x then "yes" else "no";
|
||||
setOption = n: v: if v == null then "unset ${n}" else "set ${n}=${v}";
|
||||
escape = replaceStrings [ "%" ] [ "%25" ];
|
||||
|
||||
|
@ -167,7 +166,7 @@ let
|
|||
sidebarSection = ''
|
||||
# Sidebar
|
||||
set sidebar_visible = yes
|
||||
set sidebar_short_path = ${yesno cfg.sidebar.shortPath}
|
||||
set sidebar_short_path = ${lib.hm.booleans.yesNo cfg.sidebar.shortPath}
|
||||
set sidebar_width = ${toString cfg.sidebar.width}
|
||||
set sidebar_format = '${cfg.sidebar.format}'
|
||||
'';
|
||||
|
@ -204,8 +203,10 @@ let
|
|||
|
||||
# GPG section
|
||||
set crypt_use_gpgme = yes
|
||||
set crypt_autosign = ${yesno (gpg.signByDefault or false)}
|
||||
set crypt_opportunistic_encrypt = ${yesno (gpg.encryptByDefault or false)}
|
||||
set crypt_autosign = ${lib.hm.booleans.yesNo (gpg.signByDefault or false)}
|
||||
set crypt_opportunistic_encrypt = ${
|
||||
lib.hm.booleans.yesNo (gpg.encryptByDefault or false)
|
||||
}
|
||||
set pgp_use_gpg_agent = yes
|
||||
set mbox_type = ${if maildir != null then "Maildir" else "mbox"}
|
||||
set sort = "${cfg.sort}"
|
||||
|
|
|
@ -24,7 +24,7 @@ let
|
|||
max-items ${toString cfg.maxItems}
|
||||
browser ${cfg.browser}
|
||||
reload-threads ${toString cfg.reloadThreads}
|
||||
auto-reload ${if cfg.autoReload then "yes" else "no"}
|
||||
auto-reload ${lib.hm.booleans.yesNo cfg.autoReload}
|
||||
${optionalString (cfg.reloadTime != null)
|
||||
(toString "reload-time ${toString cfg.reloadTime}")}
|
||||
prepopulate-query-feeds yes
|
||||
|
|
|
@ -12,10 +12,8 @@ let
|
|||
toIni = generators.toINI {
|
||||
mkKeyValue = key: value:
|
||||
let
|
||||
value' = if isBool value then
|
||||
(if value then "yes" else "no")
|
||||
else
|
||||
toString value;
|
||||
value' =
|
||||
(if isBool value then lib.hm.booleans.yesNo else toString) value;
|
||||
in "${key} = ${value'}";
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ let
|
|||
then " ${entry.address}"
|
||||
else " [${entry.address}]:${toString entry.port}";
|
||||
|
||||
yn = flag: if flag then "yes" else "no";
|
||||
|
||||
unwords = builtins.concatStringsSep " ";
|
||||
|
||||
bindOptions = {
|
||||
|
@ -284,7 +282,7 @@ let
|
|||
matchBlockStr = cf: concatStringsSep "\n" (
|
||||
["Host ${cf.host}"]
|
||||
++ optional (cf.port != null) " Port ${toString cf.port}"
|
||||
++ optional (cf.forwardAgent != null) " ForwardAgent ${yn cf.forwardAgent}"
|
||||
++ optional (cf.forwardAgent != null) " ForwardAgent ${lib.hm.booleans.yesNo cf.forwardAgent}"
|
||||
++ optional cf.forwardX11 " ForwardX11 yes"
|
||||
++ optional cf.forwardX11Trusted " ForwardX11Trusted yes"
|
||||
++ optional cf.identitiesOnly " IdentitiesOnly yes"
|
||||
|
@ -296,7 +294,7 @@ let
|
|||
" ServerAliveInterval ${toString cf.serverAliveInterval}"
|
||||
++ optional (cf.serverAliveCountMax != 3)
|
||||
" ServerAliveCountMax ${toString cf.serverAliveCountMax}"
|
||||
++ optional (cf.compression != null) " Compression ${yn cf.compression}"
|
||||
++ optional (cf.compression != null) " Compression ${lib.hm.booleans.yesNo cf.compression}"
|
||||
++ optional (!cf.checkHostIP) " CheckHostIP no"
|
||||
++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}"
|
||||
++ optional (cf.proxyJump != null) " ProxyJump ${cf.proxyJump}"
|
||||
|
@ -498,11 +496,11 @@ in
|
|||
)}
|
||||
|
||||
Host *
|
||||
ForwardAgent ${yn cfg.forwardAgent}
|
||||
Compression ${yn cfg.compression}
|
||||
ForwardAgent ${lib.hm.booleans.yesNo cfg.forwardAgent}
|
||||
Compression ${lib.hm.booleans.yesNo cfg.compression}
|
||||
ServerAliveInterval ${toString cfg.serverAliveInterval}
|
||||
ServerAliveCountMax ${toString cfg.serverAliveCountMax}
|
||||
HashKnownHosts ${yn cfg.hashKnownHosts}
|
||||
HashKnownHosts ${lib.hm.booleans.yesNo cfg.hashKnownHosts}
|
||||
UserKnownHostsFile ${cfg.userKnownHostsFile}
|
||||
ControlMaster ${cfg.controlMaster}
|
||||
ControlPath ${cfg.controlPath}
|
||||
|
|
|
@ -365,11 +365,11 @@ in {
|
|||
# Generated by Nix
|
||||
${optionalString (cfg.caseSensitive != null) ''
|
||||
zstyle ':prezto:*:*' case-sensitive '${
|
||||
if cfg.caseSensitive then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.caseSensitive
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.color != null) ''
|
||||
zstyle ':prezto:*:*' color '${if cfg.color then "yes" else "no"}'
|
||||
zstyle ':prezto:*:*' color '${lib.hm.booleans.yesNo cfg.color}'
|
||||
''}
|
||||
${optionalString (cfg.pmoduleDirs != [ ]) ''
|
||||
zstyle ':prezto:load' pmodule-dirs ${
|
||||
|
@ -410,12 +410,12 @@ in {
|
|||
''}
|
||||
${optionalString (cfg.editor.dotExpansion != null) ''
|
||||
zstyle ':prezto:module:editor' dot-expansion '${
|
||||
if cfg.editor.dotExpansion then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.editor.dotExpansion
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.editor.promptContext != null) ''
|
||||
zstyle ':prezto:module:editor' ps-context '${
|
||||
if cfg.editor.promptContext then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.editor.promptContext
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.git.submoduleIgnore != null) ''
|
||||
|
@ -447,27 +447,27 @@ in {
|
|||
''}
|
||||
${optionalString (cfg.python.virtualenvAutoSwitch != null) ''
|
||||
zstyle ':prezto:module:python:virtualenv' auto-switch '${
|
||||
if cfg.python.virtualenvAutoSwitch then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.python.virtualenvAutoSwitch
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.python.virtualenvInitialize != null) ''
|
||||
zstyle ':prezto:module:python:virtualenv' initialize '${
|
||||
if cfg.python.virtualenvInitialize then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.python.virtualenvInitialize
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.ruby.chrubyAutoSwitch != null) ''
|
||||
zstyle ':prezto:module:ruby:chruby' auto-switch '${
|
||||
if cfg.ruby.chrubyAutoSwitch then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.ruby.chrubyAutoSwitch
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.screen.autoStartLocal != null) ''
|
||||
zstyle ':prezto:module:screen:auto-start' local '${
|
||||
if cfg.screen.autoStartLocal then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.screen.autoStartLocal
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.screen.autoStartRemote != null) ''
|
||||
zstyle ':prezto:module:screen:auto-start' remote '${
|
||||
if cfg.screen.autoStartRemote then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.screen.autoStartRemote
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.ssh.identities != [ ]) ''
|
||||
|
@ -502,7 +502,7 @@ in {
|
|||
''}
|
||||
${optionalString (cfg.terminal.autoTitle != null) ''
|
||||
zstyle ':prezto:module:terminal' auto-title '${
|
||||
if cfg.terminal.autoTitle then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.terminal.autoTitle
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.terminal.windowTitleFormat != null) ''
|
||||
|
@ -516,17 +516,17 @@ in {
|
|||
''}
|
||||
${optionalString (cfg.tmux.autoStartLocal != null) ''
|
||||
zstyle ':prezto:module:tmux:auto-start' local '${
|
||||
if cfg.tmux.autoStartLocal then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.tmux.autoStartLocal
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.tmux.autoStartRemote != null) ''
|
||||
zstyle ':prezto:module:tmux:auto-start' remote '${
|
||||
if cfg.tmux.autoStartRemote then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.tmux.autoStartRemote
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.tmux.itermIntegration != null) ''
|
||||
zstyle ':prezto:module:tmux:iterm' integrate '${
|
||||
if cfg.tmux.itermIntegration then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.tmux.itermIntegration
|
||||
}'
|
||||
''}
|
||||
${optionalString (cfg.tmux.defaultSessionName != null) ''
|
||||
|
@ -534,7 +534,7 @@ in {
|
|||
''}
|
||||
${optionalString (cfg.utility.safeOps != null) ''
|
||||
zstyle ':prezto:module:utility' safe-ops '${
|
||||
if cfg.utility.safeOps then "yes" else "no"
|
||||
lib.hm.booleans.yesNo cfg.utility.safeOps
|
||||
}'
|
||||
''}
|
||||
${cfg.extraConfig}
|
||||
|
|
|
@ -13,7 +13,7 @@ let
|
|||
mkKeyValue = key: value:
|
||||
let
|
||||
value' = if isBool value then
|
||||
(if value then "yes" else "no")
|
||||
(lib.hm.booleans.yesNo value)
|
||||
else if isString value then
|
||||
''"${value}"''
|
||||
else
|
||||
|
|
|
@ -161,13 +161,13 @@ let
|
|||
"floating_modifier ${floating.modifier}"
|
||||
(windowBorderString window floating)
|
||||
"hide_edge_borders ${window.hideEdgeBorders}"
|
||||
"force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"}"
|
||||
"focus_follows_mouse ${if focus.followMouse then "yes" else "no"}"
|
||||
"force_focus_wrapping ${lib.hm.booleans.yesNo focus.forceWrapping}"
|
||||
"focus_follows_mouse ${lib.hm.booleans.yesNo focus.followMouse}"
|
||||
"focus_on_window_activation ${focus.newWindow}"
|
||||
"mouse_warping ${if focus.mouseWarping then "output" else "none"}"
|
||||
"workspace_layout ${workspaceLayout}"
|
||||
"workspace_auto_back_and_forth ${
|
||||
if workspaceAutoBackAndForth then "yes" else "no"
|
||||
lib.hm.booleans.yesNo workspaceAutoBackAndForth
|
||||
}"
|
||||
"client.focused ${colorSetStr colors.focused}"
|
||||
"client.focused_inactive ${colorSetStr colors.focusedInactive}"
|
||||
|
|
|
@ -87,10 +87,10 @@ rec {
|
|||
"status_command ${statusCommand}")
|
||||
"${moduleName}bar_command ${command}"
|
||||
(optionalString (workspaceButtons != null)
|
||||
"workspace_buttons ${if workspaceButtons then "yes" else "no"}")
|
||||
"workspace_buttons ${lib.hm.booleans.yesNo workspaceButtons}")
|
||||
(optionalString (workspaceNumbers != null)
|
||||
"strip_workspace_numbers ${
|
||||
if !workspaceNumbers then "yes" else "no"
|
||||
lib.hm.booleans.yesNo (!workspaceNumbers)
|
||||
}")
|
||||
(optionalString (trayOutput != null) "tray_output ${trayOutput}")
|
||||
(optionals colorsNotNull (indent
|
||||
|
|
|
@ -494,10 +494,7 @@ in {
|
|||
default = if isSway then "yes" else true;
|
||||
description = "Whether focus should follow the mouse.";
|
||||
apply = val:
|
||||
if (isSway && isBool val) then
|
||||
(if val then "yes" else "no")
|
||||
else
|
||||
val;
|
||||
if (isSway && isBool val) then (lib.hm.booleans.yesNo val) else val;
|
||||
};
|
||||
|
||||
forceWrapping = mkOption {
|
||||
|
|
|
@ -270,13 +270,13 @@ let
|
|||
"floating_modifier ${floating.modifier}"
|
||||
(windowBorderString window floating)
|
||||
"hide_edge_borders ${window.hideEdgeBorders}"
|
||||
"focus_wrapping ${if focus.forceWrapping then "yes" else "no"}"
|
||||
"focus_wrapping ${lib.hm.booleans.yesNo focus.forceWrapping}"
|
||||
"focus_follows_mouse ${focus.followMouse}"
|
||||
"focus_on_window_activation ${focus.newWindow}"
|
||||
"mouse_warping ${if focus.mouseWarping then "output" else "none"}"
|
||||
"workspace_layout ${workspaceLayout}"
|
||||
"workspace_auto_back_and_forth ${
|
||||
if workspaceAutoBackAndForth then "yes" else "no"
|
||||
lib.hm.booleans.yesNo workspaceAutoBackAndForth
|
||||
}"
|
||||
"client.focused ${colorSetStr colors.focused}"
|
||||
"client.focused_inactive ${colorSetStr colors.focusedInactive}"
|
||||
|
|
Loading…
Reference in a new issue