nixpkgs-suyu/modules/programs/environment.nix
Jan Malakhovski b3f4040512 Radically change the way NixOS handles environment variables and make it possible not to use Bash as the default interactive shell.
This change does two things:

* "NixOSizes" environment variables generation. This allows some more
  error-checking and opens possibilities for a modular environment
  configuration. From now on the most of environment variables are
  generated directly by the nix code. Generating sh code that
  generates environment variables is left in a few places where
  nontrivial access to a local environment state is needed.
* By doing the first change this patch untangles bash from the
  environment configuration and makes it trivial to add a support for
  other non bash-compatible shells.

Now to the sad part. This change is quite large (and I'm not sure it's
possible to split it) and yet is not quite complete, it needs some
changes to nixpkgs to be perfect.
See !!! comments in modules/config/shells-environment.nix.

Main principle behind this change is "change environment generation
and nothing else". In particular, shell configuration principles stay
exactly the same as before.
2013-09-23 16:55:25 +00:00

79 lines
2.4 KiB
Nix

# This module defines a standard configuration for NixOS global environment.
# Most of the stuff here should probably be moved elsewhere sometime.
{ config, pkgs, ... }:
with pkgs.lib;
let
cfg = config.environment;
in
{
config = {
environment.variables =
{ LOCALE_ARCHIVE.value = "/run/current-system/sw/lib/locale/locale-archive";
LOCATE_PATH.value = "/var/cache/locatedb";
NIXPKGS_CONFIG.value = "/etc/nix/nixpkgs-config.nix";
NIX_PATH.list =
[ "/nix/var/nix/profiles/per-user/root/channels/nixos"
"nixpkgs=/etc/nixos/nixpkgs"
"nixos=/etc/nixos/nixos"
"nixos-config=/etc/nixos/configuration.nix"
"services=/etc/nixos/services"
];
PAGER.value = "less -R";
EDITOR.value = "nano";
};
environment.profiles =
[ "$HOME/.nix-profile"
"/nix/var/nix/profiles/default"
"/run/current-system/sw"
];
# !!! fix environment.profileVariables definition and then move
# most of these elsewhere
environment.profileVariables = (i:
{ PATH = [ "${i}/bin" "${i}/sbin" "${i}/lib/kde4/libexec" ];
MANPATH = [ "${i}/man" "${i}/share/man" ];
INFOPATH = [ "${i}/info" "${i}/share/info" ];
PKG_CONFIG_PATH = [ "${i}/lib/pkgconfig" ];
TERMINFO_DIRS = [ "${i}/share/terminfo" ];
PERL5LIB = [ "${i}/lib/perl5/site_perl" ];
ALSA_PLUGIN_DIRS = [ "${i}/lib/alsa-lib" ];
GST_PLUGIN_PATH = [ "${i}/lib/gstreamer-0.10" ];
KDEDIRS = [ "${i}" ];
STRIGI_PLUGIN_PATH = [ "${i}/lib/strigi/" ];
QT_PLUGIN_PATH = [ "${i}/lib/qt4/plugins" "${i}/lib/kde4/plugins" ];
QTWEBKIT_PLUGIN_PATH = [ "${i}/lib/mozilla/plugins/" ];
GTK_PATH = [ "${i}/lib/gtk-2.0" ];
XDG_CONFIG_DIRS = [ "${i}/etc/xdg" ];
XDG_DATA_DIRS = [ "${i}/share" ];
MOZ_PLUGIN_PATH = [ "${i}/lib/mozilla/plugins" ];
});
environment.extraInit =
''
# reset TERM with new TERMINFO available (if any)
export TERM=$TERM
unset ASPELL_CONF
for i in ${concatStringsSep " " (reverseList cfg.profiles)} ; do
if [ -d "$i/lib/aspell" ]; then
export ASPELL_CONF="dict-dir $i/lib/aspell"
fi
done
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
export NIX_PROFILES="${concatStringsSep " " (reverseList cfg.profiles)}"
'';
};
}