diff --git a/config.nix b/config.nix index 338be66..6e79397 100644 --- a/config.nix +++ b/config.nix @@ -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,49 +68,22 @@ 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 + # Only execute this file once per shell. + if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi + __ETC_ZPROFILE_SOURCED=1 - source $HOME/.profile.local - ''; - - environment.etc."zshenv".text = '' - autoload -U compinit && compinit autoload -U promptinit && promptinit - - 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' - source $HOME/.zshenv.local - ''; + bindkey -e + setopt autocd - 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} - - export NIX_PATH=nixpkgs=$HOME/.nix-defexpr/nixpkgs - - typeset -U NIX_PATH - typeset -U PATH - - # 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 + autoload -U compinit && compinit nixdarwin-rebuild () { case $1 in @@ -122,7 +95,65 @@ let esac } - source $HOME/.zshrc.local + 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."zshenv".text = '' + # /etc/zshenv: DO NOT EDIT -- this file has been generated automatically. + # This file is read for all shells. + + # 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 + + # 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 + + ''; + + 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 + + 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" '');