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
7let
8
9 cfg = config.environment;
10
11in
12
13{
14
15 config = {
16
17 environment.variables =
18 { NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
19 # note: many programs exec() this directly, so default options for less must not
20 # be specified here; do so in the default value of programs.less.envVariables instead
21 PAGER = lib.mkDefault "less";
22 EDITOR = lib.mkDefault "nano";
23 };
24
25 # since we set PAGER to this above, make sure it's installed
26 programs.less.enable = true;
27
28 environment.profiles = lib.mkAfter
29 [ "/nix/var/nix/profiles/default"
30 "/run/current-system/sw"
31 ];
32
33 environment.sessionVariables =
34 {
35 XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
36 };
37
38 # TODO: move most of these elsewhere
39 environment.profileRelativeSessionVariables =
40 { PATH = [ "/bin" ];
41 INFOPATH = [ "/info" "/share/info" ];
42 QTWEBKIT_PLUGIN_PATH = [ "/lib/mozilla/plugins/" ];
43 GTK_PATH = [ "/lib/gtk-2.0" "/lib/gtk-3.0" "/lib/gtk-4.0" ];
44 XDG_CONFIG_DIRS = [ "/etc/xdg" ];
45 XDG_DATA_DIRS = [ "/share" ];
46 LIBEXEC_PATH = [ "/libexec" ];
47 };
48
49 environment.pathsToLink = [ "/lib/gtk-2.0" "/lib/gtk-3.0" "/lib/gtk-4.0" ];
50
51 environment.extraInit =
52 ''
53 export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
54 export NIX_PROFILES="${builtins.concatStringsSep " " (lib.reverseList cfg.profiles)}"
55 '';
56
57 };
58
59}