summary refs log tree commit diff
path: root/nixos/modules/programs/environment.nix
blob: 4a510805b019ad938871c5f89048d5468f0d7275 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This module defines a standard configuration for NixOS global environment.

# Most of the stuff here should probably be moved elsewhere sometime.

{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.environment;

in

{

  config = {

    environment.variables =
      { LOCATE_PATH = "/var/cache/locatedb";
        NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
        PAGER = mkDefault "less -R";
        EDITOR = mkDefault "nano";
      };

    environment.sessionVariables =
      { NIX_PATH =
          [ "/nix/var/nix/profiles/per-user/root/channels/nixos"
            "nixpkgs=/etc/nixos/nixpkgs"
            "nixos-config=/etc/nixos/configuration.nix"
          ];
      };

    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_SYSTEM_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" "${i}/lib/gtk-3.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)}"
      '';

  };

}