diff --git a/config.nix b/config.nix index 43c4170..8997ccb 100644 --- a/config.nix +++ b/config.nix @@ -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 '' -iA nixdarwin.toplevel ;; ''') return 1 ;; + 'switch') nix-env -f '' -iA nixdarwin.toplevel ;; + ''') return 1 ;; esac } ''; @@ -127,7 +129,7 @@ in { nnoremap p :FZF ''; vimrcConfig.vam.pluginDictionaries = [ - { names = [ "fzfWrapper" "youcompleteme" "surround" "vim-nix" "colors-solarized" ]; } + { names = [ "fzfWrapper" "youcompleteme" "fugitive" "surround" "vim-nix" "colors-solarized" ]; } ]; }; diff --git a/modules/environment.nix b/modules/environment.nix index ace1b1c..d2e0d14 100644 --- a/modules/environment.nix +++ b/modules/environment.nix @@ -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";