1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

add environment.shellAliases

This commit is contained in:
Daiderd Jordan 2016-10-21 20:56:23 +02:00
parent c02f1dc81f
commit e968db6224
No known key found for this signature in database
GPG key ID: D02435D05B810C96
2 changed files with 31 additions and 16 deletions

View file

@ -26,23 +26,27 @@ let
pkgs.silver-searcher
pkgs.tmux
pkgs.nix-prefetch-scripts
pkgs.nix-repl
pkgs.nox
];
environment.variables.EDITOR = "vim";
environment.variables.HOMEBREW_CASK_OPTS = "--appdir=/Applications/cask";
environment.variables.GIT_SSL_CAINFO = "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt";
environment.variables.SSL_CERT_FILE = "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt";
environment.etc."profile".text = ''
source ${config.system.build.setEnvironment}
source ${config.system.build.setAliases}
conf=$HOME/src/nixpkgs-config
pkgs=$HOME/.nix-defexpr/nixpkgs
alias ls='ls -G'
alias l='ls -hl'
source ${config.system.build.setEnvironment}
'';
environment.shellAliases.l = "ls -lh";
environment.shellAliases.ls = "ls -G";
environment.etc."tmux.conf".text = ''
set -g default-command "reattach-to-user-namespace -l $SHELL"
set -g default-terminal "screen-256color"
@ -68,9 +72,6 @@ let
export PROMPT='%B%(?..[%?] )%b> '
export RPROMPT='%F{green}%~%f'
export SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
export GIT_SSL_CAINFO=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
export PATH=/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin''${PATH:+:$PATH}
export PATH=$HOME/.nix-profile/bin:$HOME/.nix-profile/bin''${PATH:+:$PATH}
@ -79,7 +80,8 @@ let
nixdarwin-rebuild () {
case $1 in
'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel ;; ''') return 1 ;;
'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel ;;
''') return 1 ;;
esac
}
'';
@ -127,7 +129,7 @@ in {
nnoremap <Leader>p :FZF<cr>
'';
vimrcConfig.vam.pluginDictionaries = [
{ names = [ "fzfWrapper" "youcompleteme" "surround" "vim-nix" "colors-solarized" ]; }
{ names = [ "fzfWrapper" "youcompleteme" "fugitive" "surround" "vim-nix" "colors-solarized" ]; }
];
};

View file

@ -9,8 +9,9 @@ let
exportVariables =
mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
exportedEnvVars =
concatStringsSep "\n" exportVariables;
aliasCommands =
mapAttrsFlatten (n: v: ''alias ${n}="${v}"'') cfg.shellAliases;
in {
options = {
@ -50,14 +51,26 @@ in {
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
environment.shellAliases = mkOption {
type = types.attrsOf types.str;
default = {};
example = { ll = "ls -l"; };
description = ''
An attribute set that maps aliases (the top level attribute names in
this option) to command strings or directly to build outputs. The
alises are added to all users' shells.
'';
};
};
config = {
system.build.setEnvironment = pkgs.writeText "set-environment" ''
${exportedEnvVars}
'';
system.build.setEnvironment = pkgs.writeText "set-environment"
(concatStringsSep "\n" exportVariables);
system.build.setAliases = pkgs.writeText "set-aliases"
(concatStringsSep "\n" aliasCommands);
system.path = pkgs.buildEnv {
name = "system-path";