mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
add environment.profiles
This commit is contained in:
parent
5c1fc8a85c
commit
2ad1229c71
3 changed files with 79 additions and 20 deletions
|
@ -33,13 +33,26 @@ in {
|
|||
|
||||
environment.systemPath = mkOption {
|
||||
type = types.loeOf types.path;
|
||||
default = [ "$HOME/.nix-profile" "/run/current-system/sw" "/nix/var/nix/profiles/default" "/usr/local" ];
|
||||
default = (reverseList cfg.profiles) ++ [ "/usr/local" "/usr" "" ];
|
||||
description = ''
|
||||
The set of paths that are added to PATH
|
||||
'';
|
||||
apply = x: if isList x then makeBinPath x else x;
|
||||
};
|
||||
|
||||
environment.profiles = mkOption {
|
||||
type = types.listOf types.path;
|
||||
default =
|
||||
[ # Use user, default and system profiles.
|
||||
"$HOME/.nix-profile"
|
||||
"/nix/var/nix/profiles/default"
|
||||
"/run/current-system/sw"
|
||||
];
|
||||
description = ''
|
||||
A list of profiles used to setup the global environment.
|
||||
'';
|
||||
};
|
||||
|
||||
environment.extraOutputsToInstall = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
|
@ -82,6 +95,16 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
environment.interactiveShellInit = mkOption {
|
||||
default = "";
|
||||
description = ''
|
||||
Shell script code called during interactive shell initialisation.
|
||||
This code is asumed to be shell-independent, which means you should
|
||||
stick to pure sh without sh word split.
|
||||
'';
|
||||
type = types.lines;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
|
@ -95,5 +118,18 @@ in {
|
|||
inherit (cfg) extraOutputsToInstall;
|
||||
};
|
||||
|
||||
environment.extraInit = ''
|
||||
# reset TERM with new TERMINFO available (if any)
|
||||
export TERM=$TERM
|
||||
|
||||
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
|
||||
export NIX_PROFILES="${concatStringsSep " " (reverseList cfg.profiles)}"
|
||||
'';
|
||||
|
||||
environment.variables =
|
||||
{ EDITOR = mkDefault "nano";
|
||||
PAGER = mkDefault "less -R";
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -15,6 +15,17 @@ let
|
|||
makeWrapper ${pkgs.bash}/bin/bash $out/bin/bash
|
||||
'';
|
||||
|
||||
|
||||
interactiveShellInit = ''
|
||||
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
|
||||
${config.system.build.setEnvironment}
|
||||
${config.system.build.setAliases}
|
||||
|
||||
${config.environment.extraInit}
|
||||
${config.environment.interactiveShellInit}
|
||||
${cfg.interactiveShellInit}
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -53,7 +64,7 @@ in
|
|||
pkgs.bash
|
||||
];
|
||||
|
||||
environment.variables.SHELL = "${cfg.shell}";
|
||||
environment.variables.SHELL = mkDefault "${cfg.shell}";
|
||||
|
||||
environment.etc."bashrc".text = ''
|
||||
# /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
|
||||
|
@ -63,12 +74,7 @@ in
|
|||
if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
|
||||
__ETC_BASHRC_SOURCED=1
|
||||
|
||||
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
|
||||
${config.system.build.setEnvironment}
|
||||
${config.system.build.setAliases}
|
||||
|
||||
${cfg.interactiveShellInit}
|
||||
${config.environment.extraInit}
|
||||
${interactiveShellInit}
|
||||
|
||||
# Read system-wide modifications.
|
||||
if test -f /etc/bash.local; then
|
||||
|
|
|
@ -15,6 +15,33 @@ let
|
|||
makeWrapper ${pkgs.zsh}/bin/zsh $out/bin/zsh
|
||||
'';
|
||||
|
||||
interactiveShellInit = ''
|
||||
# history defaults
|
||||
SAVEHIST=2000
|
||||
HISTSIZE=2000
|
||||
HISTFILE=$HOME/.zsh_history
|
||||
|
||||
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
|
||||
|
||||
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
|
||||
${config.system.build.setEnvironment}
|
||||
${config.system.build.setAliases}
|
||||
|
||||
${config.environment.extraInit}
|
||||
${config.environment.interactiveShellInit}
|
||||
|
||||
${cfg.interactiveShellInit}
|
||||
${cfg.promptInit}
|
||||
|
||||
# Tell zsh how to find installed completions
|
||||
for p in ''${(z)NIX_PROFILES}; do
|
||||
fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions)
|
||||
done
|
||||
|
||||
${optionalString cfg.enableCompletion "autoload -U compinit && compinit"}
|
||||
${optionalString cfg.enableBashCompletion "autoload -U bashcompinit && bashcompinit"}
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -93,7 +120,7 @@ in
|
|||
pkgs.zsh
|
||||
];
|
||||
|
||||
environment.variables.SHELL = "${cfg.shell}";
|
||||
environment.variables.SHELL = mkDefault "${cfg.shell}";
|
||||
|
||||
environment.etc."zshenv".text = ''
|
||||
# /etc/zshenv: DO NOT EDIT -- this file has been generated automatically.
|
||||
|
@ -136,17 +163,7 @@ in
|
|||
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
|
||||
__ETC_ZSHRC_SOURCED=1
|
||||
|
||||
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
|
||||
${config.system.build.setEnvironment}
|
||||
${config.system.build.setAliases}
|
||||
|
||||
${cfg.interactiveShellInit}
|
||||
|
||||
${cfg.promptInit}
|
||||
${optionalString cfg.enableCompletion "autoload -U compinit && compinit"}
|
||||
${optionalString cfg.enableBashCompletion "autoload -U bashcompinit && bashcompinit"}
|
||||
|
||||
${config.environment.extraInit}
|
||||
${interactiveShellInit}
|
||||
|
||||
# Read system-wide modifications.
|
||||
if test -f /etc/zshrc.local; then
|
||||
|
|
Loading…
Reference in a new issue