summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/environment.nix
blob: 698c61764f4f7f25c1a1c945a146d6ce3378da17 (plain)
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
# This module defines a standard configuration for NixOS global environment.

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

{ config, lib, ... }:

let

  cfg = config.environment;

in

{

  config = {

    environment.variables = {
      NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
      # note: many programs exec() this directly, so default options for less must not
      # be specified here; do so in the default value of programs.less.envVariables instead
      PAGER = lib.mkDefault "less";
      EDITOR = lib.mkDefault "nano";
    };

    # since we set PAGER to this above, make sure it's installed
    programs.less.enable = true;

    environment.profiles = lib.mkAfter [
      "/nix/var/nix/profiles/default"
      "/run/current-system/sw"
    ];

    environment.sessionVariables = {
      XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
    };

    # TODO: move most of these elsewhere
    environment.profileRelativeSessionVariables = {
      PATH = [ "/bin" ];
      INFOPATH = [
        "/info"
        "/share/info"
      ];
      QTWEBKIT_PLUGIN_PATH = [ "/lib/mozilla/plugins/" ];
      GTK_PATH = [
        "/lib/gtk-2.0"
        "/lib/gtk-3.0"
        "/lib/gtk-4.0"
      ];
      XDG_CONFIG_DIRS = [ "/etc/xdg" ];
      XDG_DATA_DIRS = [ "/share" ];
      LIBEXEC_PATH = [ "/libexec" ];
    };

    environment.pathsToLink = [
      "/lib/gtk-2.0"
      "/lib/gtk-3.0"
      "/lib/gtk-4.0"
    ];

    environment.extraInit = ''
      export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
      export NIX_PROFILES="${builtins.concatStringsSep " " (lib.reverseList cfg.profiles)}"
    '';

  };

}