1# This module defines a standard configuration for NixOS global environment.
2
3# Most of the stuff here should probably be moved elsewhere sometime.
4
5{ config, lib, ... }:
6
7with lib;
8
9let
10
11 cfg = config.environment;
12
13in
14
15{
16
17 config = {
18
19 environment.variables =
20 { NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
21 PAGER = mkDefault "less -R";
22 EDITOR = mkDefault "nano";
23 XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
24 };
25
26 environment.profiles = mkAfter
27 [ "/nix/var/nix/profiles/default"
28 "/run/current-system/sw"
29 ];
30
31 # TODO: move most of these elsewhere
32 environment.profileRelativeSessionVariables =
33 { PATH = [ "/bin" ];
34 INFOPATH = [ "/info" "/share/info" ];
35 KDEDIRS = [ "" ];
36 QT_PLUGIN_PATH = [ "/lib/qt4/plugins" "/lib/kde4/plugins" ];
37 QTWEBKIT_PLUGIN_PATH = [ "/lib/mozilla/plugins/" ];
38 GTK_PATH = [ "/lib/gtk-2.0" "/lib/gtk-3.0" ];
39 XDG_CONFIG_DIRS = [ "/etc/xdg" ];
40 XDG_DATA_DIRS = [ "/share" ];
41 MOZ_PLUGIN_PATH = [ "/lib/mozilla/plugins" ];
42 LIBEXEC_PATH = [ "/lib/libexec" ];
43 };
44
45 environment.extraInit =
46 ''
47 unset ASPELL_CONF
48 for i in ${concatStringsSep " " (reverseList cfg.profiles)} ; do
49 if [ -d "$i/lib/aspell" ]; then
50 export ASPELL_CONF="dict-dir $i/lib/aspell"
51 fi
52 done
53
54 export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
55 export NIX_PROFILES="${concatStringsSep " " (reverseList cfg.profiles)}"
56 '';
57
58 };
59
60}