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 XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
35 };
36
37 # TODO: move most of these elsewhere
38 environment.profileRelativeSessionVariables = {
39 PATH = [ "/bin" ];
40 INFOPATH = [
41 "/info"
42 "/share/info"
43 ];
44 QTWEBKIT_PLUGIN_PATH = [ "/lib/mozilla/plugins/" ];
45 GTK_PATH = [
46 "/lib/gtk-2.0"
47 "/lib/gtk-3.0"
48 "/lib/gtk-4.0"
49 ];
50 XDG_CONFIG_DIRS = [ "/etc/xdg" ];
51 XDG_DATA_DIRS = [ "/share" ];
52 LIBEXEC_PATH = [ "/libexec" ];
53 };
54
55 environment.pathsToLink = [
56 "/lib/gtk-2.0"
57 "/lib/gtk-3.0"
58 "/lib/gtk-4.0"
59 ];
60
61 environment.extraInit = ''
62 export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
63 export NIX_PROFILES="${builtins.concatStringsSep " " (lib.reverseList cfg.profiles)}"
64 '';
65
66 };
67
68}