mirror of
https://github.com/nix-community/home-manager
synced 2024-06-14 02:33:38 +02:00
Merge c67b06ff92
into 6d3b6dc922
This commit is contained in:
commit
74bbf6e939
|
@ -9,11 +9,20 @@ rec {
|
||||||
''"${v}"''
|
''"${v}"''
|
||||||
else if builtins.isList v then
|
else if builtins.isList v then
|
||||||
"(${lib.concatStringsSep " " (map toZshValue v)})"
|
"(${lib.concatStringsSep " " (map toZshValue v)})"
|
||||||
|
else if builtins.isAttrs v then
|
||||||
|
"(${
|
||||||
|
lib.concatStringsSep " "
|
||||||
|
(lib.mapAttrsToList (n: v: "[${lib.escapeShellArg n}]=${toZshValue v}")
|
||||||
|
v)
|
||||||
|
})"
|
||||||
else
|
else
|
||||||
''"${toString v}"'';
|
''"${toString v}"'';
|
||||||
|
|
||||||
# Produces a Zsh shell like definition statement
|
# Produces a Zsh shell like definition statement
|
||||||
define = n: v: "${n}=${toZshValue v}";
|
define = n: v:
|
||||||
|
"${lib.optionalString (builtins.isAttrs v) "typeset -A "}${n}=${
|
||||||
|
toZshValue v
|
||||||
|
}";
|
||||||
|
|
||||||
# Given an attribute set containing shell variable names and their
|
# Given an attribute set containing shell variable names and their
|
||||||
# assignments, this function produces a string containing a definition
|
# assignments, this function produces a string containing a definition
|
||||||
|
|
|
@ -501,7 +501,10 @@ in
|
||||||
localVariables = mkOption {
|
localVariables = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = {};
|
default = {};
|
||||||
example = { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=["dir" "vcs"]; };
|
example = {
|
||||||
|
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=["dir" "vcs"];
|
||||||
|
ZSH_HIGHLIGHT_STYLES={unknown-token="bg=red,fg=white,bold";};
|
||||||
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Extra local variables defined at the top of {file}`.zshrc`.
|
Extra local variables defined at the top of {file}`.zshrc`.
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
zsh-local-variables = ./local-variables.nix;
|
||||||
zsh-session-variables = ./session-variables.nix;
|
zsh-session-variables = ./session-variables.nix;
|
||||||
zsh-history-path-new-default = ./history-path-new-default.nix;
|
zsh-history-path-new-default = ./history-path-new-default.nix;
|
||||||
zsh-history-path-new-custom = ./history-path-new-custom.nix;
|
zsh-history-path-new-custom = ./history-path-new-custom.nix;
|
||||||
|
|
40
tests/modules/programs/zsh/local-variables.nix
Normal file
40
tests/modules/programs/zsh/local-variables.nix
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
localVariables = rec {
|
||||||
|
V1 = true;
|
||||||
|
V2 = false;
|
||||||
|
V3 = "some-string";
|
||||||
|
V4 = 42;
|
||||||
|
V5 = builtins.attrValues V6;
|
||||||
|
V6 = {
|
||||||
|
a = V1;
|
||||||
|
b = V2;
|
||||||
|
c = V3;
|
||||||
|
d = V4;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.zsh = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.zshrc
|
||||||
|
assertFileRegex home-files/.zshrc '^V1=true$'
|
||||||
|
assertFileRegex home-files/.zshrc '^V2=false$'
|
||||||
|
assertFileRegex home-files/.zshrc '^V3="some-string"$'
|
||||||
|
assertFileRegex home-files/.zshrc '^V4="42"$'
|
||||||
|
assertFileRegex home-files/.zshrc '^V5=[(]true false "some-string" "42"[)]$'
|
||||||
|
assertFileContains home-files/.zshrc ${
|
||||||
|
lib.escapeShellArg ''
|
||||||
|
typeset -A V6=(['a']=true ['b']=false ['c']="some-string" ['d']="42")''
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user