mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-13 20:30:02 +00:00
add variables option to programs.zsh module
This commit is contained in:
parent
2ad1229c71
commit
0c4fbaf0d9
3 changed files with 27 additions and 35 deletions
|
@ -42,7 +42,7 @@
|
|||
services.activate-system.enable = true;
|
||||
|
||||
programs.tmux.enable = true;
|
||||
programs.tmux.loginShell = "${config.programs.zsh.shell} -l";
|
||||
programs.tmux.loginShell = "$SHELL -l";
|
||||
programs.tmux.enableSensible = true;
|
||||
programs.tmux.enableMouse = true;
|
||||
programs.tmux.enableFzf = true;
|
||||
|
@ -58,6 +58,11 @@
|
|||
programs.zsh.enable = true;
|
||||
programs.zsh.enableBashCompletion = true;
|
||||
|
||||
programs.zsh.variables.cfg = "$HOME/.nixpkgs/darwin-config.nix";
|
||||
programs.zsh.variables.darwin = "$HOME/.nix-defexpr/darwin";
|
||||
programs.zsh.variables.pkgs = "$HOME/.nix-defexpr/nixpkgs";
|
||||
|
||||
|
||||
programs.zsh.promptInit = ''
|
||||
autoload -U promptinit && promptinit
|
||||
|
||||
|
@ -65,19 +70,7 @@
|
|||
RPROMPT='%F{green}%~%f'
|
||||
'';
|
||||
|
||||
programs.zsh.shellInit = ''
|
||||
cfg=$HOME/.nixpkgs/darwin-config.nix
|
||||
darwin=$HOME/.nix-defexpr/darwin
|
||||
pkgs=$HOME/.nix-defexpr/nixpkgs
|
||||
'';
|
||||
|
||||
programs.zsh.loginShellInit = ''
|
||||
|
||||
bindkey -e
|
||||
setopt autocd
|
||||
|
||||
autoload -U compinit && compinit
|
||||
|
||||
nix () {
|
||||
cmd=$1
|
||||
shift
|
||||
|
@ -102,12 +95,8 @@
|
|||
'';
|
||||
|
||||
programs.zsh.interactiveShellInit = ''
|
||||
# history defaults
|
||||
SAVEHIST=2000
|
||||
HISTSIZE=2000
|
||||
HISTFILE=$HOME/.zsh_history
|
||||
|
||||
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
|
||||
bindkey -e
|
||||
setopt AUTOCD
|
||||
'';
|
||||
|
||||
environment.variables.EDITOR = "vim";
|
||||
|
@ -140,6 +129,7 @@
|
|||
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${pkgs.tmux}/bin/tmux $out/bin/tmux \
|
||||
--set __ETC_BASHRC_SOURCED "" \
|
||||
--set __ETC_ZPROFILE_SOURCED "" \
|
||||
--set __ETC_ZSHENV_SOURCED "" \
|
||||
--set __ETC_ZSHRC_SOURCED "" \
|
||||
|
|
|
@ -6,7 +6,7 @@ let
|
|||
|
||||
cfg = config.programs.bash;
|
||||
|
||||
bash = pkgs.runCommand pkgs.zsh.name
|
||||
shell = pkgs.runCommand pkgs.zsh.name
|
||||
{ buildInputs = [ pkgs.makeWrapper ]; }
|
||||
''
|
||||
source $stdenv/setup
|
||||
|
@ -39,14 +39,6 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
programs.bash.shell = mkOption {
|
||||
type = types.path;
|
||||
default = "${bash}/bin/bash";
|
||||
description = ''
|
||||
Zsh shell to use.
|
||||
'';
|
||||
};
|
||||
|
||||
programs.bash.interactiveShellInit = mkOption {
|
||||
default = "";
|
||||
description = ''
|
||||
|
@ -64,7 +56,7 @@ in
|
|||
pkgs.bash
|
||||
];
|
||||
|
||||
environment.variables.SHELL = mkDefault "${cfg.shell}";
|
||||
environment.variables.SHELL = mkDefault "${shell}/bin/bash";
|
||||
|
||||
environment.etc."bashrc".text = ''
|
||||
# /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
|
||||
|
|
|
@ -6,7 +6,10 @@ let
|
|||
|
||||
cfg = config.programs.zsh;
|
||||
|
||||
zsh = pkgs.runCommand pkgs.zsh.name
|
||||
zshVariables =
|
||||
mapAttrsToList (n: v: ''${n}="${v}"'') cfg.variables;
|
||||
|
||||
shell = pkgs.runCommand pkgs.zsh.name
|
||||
{ buildInputs = [ pkgs.makeWrapper ]; }
|
||||
''
|
||||
source $stdenv/setup
|
||||
|
@ -55,12 +58,17 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
programs.zsh.shell = mkOption {
|
||||
type = types.path;
|
||||
default = "${zsh}/bin/zsh";
|
||||
programs.zsh.variables = mkOption {
|
||||
type = types.attrsOf (types.either types.str (types.listOf types.str));
|
||||
default = {};
|
||||
description = ''
|
||||
Zsh shell to use.
|
||||
A set of environment variables used in the global environment.
|
||||
These variables will be set on shell initialisation.
|
||||
The value of each variable can be either a string or a list of
|
||||
strings. The latter is concatenated, interspersed with colon
|
||||
characters.
|
||||
'';
|
||||
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
|
||||
};
|
||||
|
||||
programs.zsh.shellInit = mkOption {
|
||||
|
@ -120,7 +128,7 @@ in
|
|||
pkgs.zsh
|
||||
];
|
||||
|
||||
environment.variables.SHELL = mkDefault "${cfg.shell}";
|
||||
environment.variables.SHELL = mkDefault "${shell}/bin/zsh";
|
||||
|
||||
environment.etc."zshenv".text = ''
|
||||
# /etc/zshenv: DO NOT EDIT -- this file has been generated automatically.
|
||||
|
@ -147,6 +155,8 @@ in
|
|||
if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi
|
||||
__ETC_ZPROFILE_SOURCED=1
|
||||
|
||||
${concatStringsSep "\n" zshVariables}
|
||||
|
||||
${cfg.loginShellInit}
|
||||
|
||||
# Read system-wide modifications.
|
||||
|
|
Loading…
Add table
Reference in a new issue