diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-11-05 16:54:04 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-11-05 16:54:04 +0100 |
| commit | 380bdd293bbcd10ffa8f632572ec34e6f1314cfb (patch) | |
| tree | e9d8e346c0d6ce1ab48d8fed9e63159659d93d45 | |
| parent | efc38f72f9d38146b938c475a1b47693bc508bb6 (diff) | |
added environment.systemPath and improved zsh options
| -rw-r--r-- | config.nix | 101 | ||||
| -rw-r--r-- | modules/environment.nix | 16 | ||||
| -rw-r--r-- | modules/system.nix | 3 | ||||
| -rw-r--r-- | modules/tmux.nix | 6 |
4 files changed, 82 insertions, 44 deletions
@@ -55,7 +55,7 @@ let environment.shellAliases.l = "ls -lh"; environment.shellAliases.ls = "ls -G"; - environment.shellAliases.tmux = "${pkgs.tmux}/bin/tmux -f ${config.environment.etc."tmux.conf".source}"; + environment.shellAliases.tmux = "${pkgs.tmux}/bin/tmux"; environment.shellAliases.zsh = "${pkgs.zsh}/bin/zsh"; environment.etc."tmux.conf".text = '' @@ -68,61 +68,92 @@ let source-file $HOME/.tmux.conf.local ''; - environment.etc."profile".text = '' - source ${config.system.build.setEnvironment} - source ${config.system.build.setAliases} + environment.etc."zprofile".text = '' + # /etc/zprofile: DO NOT EDIT -- this file has been generated automatically. + # This file is read for login shells. - conf=$HOME/src/nixpkgs-config - pkgs=$HOME/.nix-defexpr/nixpkgs - - source $HOME/.profile.local - ''; + # Only execute this file once per shell. + if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi + __ETC_ZPROFILE_SOURCED=1 - environment.etc."zshenv".text = '' - autoload -U compinit && compinit autoload -U promptinit && promptinit + PROMPT='%B%(?..%? )%b⇒ ' + RPROMPT='%F{green}%~%f' bindkey -e setopt autocd - setopt inc_append_history - setopt share_history - HISTFILE=$HOME/.zhistory - HISTSIZE=4096 - SAVEHIST=$HISTSIZE - PROMPT='%B%(?..%? )%b⇒ ' - RPROMPT='%F{green}%~%f' + autoload -U compinit && compinit - source $HOME/.zshenv.local + nixdarwin-rebuild () { + case $1 in + 'build') nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel ;; + 'repl') nix-repl "$HOME/.nixpkgs/config.nix" ;; + 'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run "${pkgs.zsh}/bin/zsh -l" ;; + 'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.zsh}/bin/zsh -l ;; + "") return 1 ;; + esac + } + + conf=$HOME/src/nixpkgs-config + pkgs=$HOME/.nix-defexpr/nixpkgs + + # Read system-wide modifications. + if test -f /etc/zprofile.local; then + . /etc/zprofile.local + fi ''; - environment.etc."zshrc".text = '' - export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/bin''${PATH:+:$PATH} - 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} + environment.etc."zshenv".text = '' + # /etc/zshenv: DO NOT EDIT -- this file has been generated automatically. + # This file is read for all shells. - export NIX_PATH=nixpkgs=$HOME/.nix-defexpr/nixpkgs + # Only execute this file once per shell. + # But don't clobber the environment of interactive non-login children! + + if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi + export __ETC_ZSHENV_SOURCED=1 - typeset -U NIX_PATH + # Read system-wide modifications. + if test -f /etc/zshenv.local; then + . /etc/zshenv.local + fi + + export PATH=${config.environment.systemPath}''${PATH:+:$PATH} typeset -U PATH + export NIX_PATH=nixpkgs=$HOME/.nix-defexpr/nixpkgs + # Set up secure multi-user builds: non-root users build through the # Nix daemon. if [ "$USER" != root -a ! -w /nix/var/nix/db ]; then export NIX_REMOTE=daemon fi - nixdarwin-rebuild () { - case $1 in - 'build') nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel ;; - 'repl') nix-repl "$HOME/.nixpkgs/config.nix" ;; - 'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run "${pkgs.zsh}/bin/zsh -l" ;; - 'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.zsh}/bin/zsh -l ;; - "") return 1 ;; - esac - } + ''; + + environment.etc."zshrc".text = '' + # /etc/zshrc: DO NOT EDIT -- this file has been generated automatically. + # This file is read for interactive shells. + + # Only execute this file once per shell. + if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi + __ETC_ZSHRC_SOURCED=1 + + # history defaults + SAVEHIST=2000 + HISTSIZE=2000 + HISTFILE=$HOME/.zsh_history - source $HOME/.zshrc.local + setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK + + ${config.system.build.setEnvironment} + ${config.system.build.setAliases} + + # Read system-wide modifications. + if test -f /etc/zshrc.local; then + . /etc/zshrc.local + fi ''; }; diff --git a/modules/environment.nix b/modules/environment.nix index 58a5e25..37cd652 100644 --- a/modules/environment.nix +++ b/modules/environment.nix @@ -31,6 +31,15 @@ in { ''; }; + environment.systemPath = mkOption { + type = types.loeOf types.path; + default = [ "$HOME/.nix-profile" "/run/current-system/sw" "/nix/var/nix/profiles/default" "/usr/local" ]; + description = '' + The set of paths that are added to PATH + ''; + apply = x: if isList x then makeBinPath x else x; + }; + environment.extraOutputsToInstall = mkOption { type = types.listOf types.str; default = [ ]; @@ -66,11 +75,8 @@ in { config = { - system.build.setEnvironment = pkgs.writeText "set-environment" - (concatStringsSep "\n" exportVariables); - - system.build.setAliases = pkgs.writeText "set-aliases" - (concatStringsSep "\n" aliasCommands); + system.build.setEnvironment = concatStringsSep "\n" exportVariables; + system.build.setAliases = concatStringsSep "\n" aliasCommands; system.path = pkgs.buildEnv { name = "system-path"; diff --git a/modules/system.nix b/modules/system.nix index 13744a4..e80f4c9 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -39,7 +39,6 @@ in { system.build = mkOption { internal = true; - type = types.attrsOf types.package; default = {}; description = '' Attribute set of derivation used to setup the system. @@ -97,6 +96,8 @@ in { # Prevent the current configuration from being garbage-collected. ln -sfn /run/current-system /nix/var/nix/gcroots/current-system + ${cfg.activationScripts.etc.text} + exit $_status ''; diff --git a/modules/tmux.nix b/modules/tmux.nix index c54d0a2..18967d2 100644 --- a/modules/tmux.nix +++ b/modules/tmux.nix @@ -66,7 +66,7 @@ in { config = { - programs.tmux.config = lib.concatStringsSep "\n" tmuxConfigs; + programs.tmux.config = concatStringsSep "\n" tmuxConfigs; programs.tmux.text.login-shell = if stdenv.isDarwin then '' set -g default-command "reattach-to-user-namespace ${cfg.loginShell}" @@ -113,9 +113,9 @@ in { bind v split-window -h -c '#{pane_current_path}' bind -t vi-copy v begin-selection - '' + lib.optionalString stdenv.isLinux '' + '' + optionalString stdenv.isLinux '' bind -t vi-copy y copy-selection - '' + lib.optionalString stdenv.isDarwin '' + '' + optionalString stdenv.isDarwin '' bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" ''); |
