mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 13:10:33 +00:00
In environment.variables, unify "value" and "list"
This commit is contained in:
parent
3840e96e79
commit
9df40867b9
|
@ -49,7 +49,7 @@ with pkgs.lib;
|
|||
# FIXME: This variable is no longer needed, but we'll keep it
|
||||
# around for a while for applications linked against old
|
||||
# fontconfig builds.
|
||||
environment.variables.FONTCONFIG_FILE.value = "/etc/fonts/fonts.conf";
|
||||
environment.variables.FONTCONFIG_FILE = "/etc/fonts/fonts.conf";
|
||||
|
||||
environment.systemPackages = [ pkgs.fontconfig ];
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ in
|
|||
|
||||
environment.systemPackages = [ glibcLocales ];
|
||||
|
||||
environment.variables.LANG.value = config.i18n.defaultLocale;
|
||||
environment.variables.LANG = config.i18n.defaultLocale;
|
||||
|
||||
# ‘/etc/locale.conf’ is used by systemd.
|
||||
environment.etc = singleton
|
||||
|
|
|
@ -9,40 +9,6 @@ let
|
|||
|
||||
cfg = config.environment;
|
||||
|
||||
environOpts = { name, config, ... }: {
|
||||
|
||||
options = {
|
||||
|
||||
value = mkOption {
|
||||
example = "/foo/bin";
|
||||
description =
|
||||
''
|
||||
Variable value.
|
||||
Exactly one of this or <option>list</option> must be set.
|
||||
'';
|
||||
type = types.uniq types.string;
|
||||
};
|
||||
|
||||
list = mkOption {
|
||||
default = null;
|
||||
example = [ "/foo/bin" "/bar/bin" ];
|
||||
description =
|
||||
''
|
||||
Variable value.
|
||||
Exactly one of this or <option>value</option> must be set.
|
||||
'';
|
||||
type = types.nullOr (types.listOf types.string);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
value = mkIf (config.list != null)
|
||||
(concatStringsSep ":" config.list);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -53,9 +19,15 @@ in
|
|||
default = {};
|
||||
description = ''
|
||||
A set of environment variables used in the global environment.
|
||||
The value of each variable can be either a string or a list of
|
||||
strings. The latter is concatenated, interspersed with colon
|
||||
characters.
|
||||
'';
|
||||
type = types.attrsOf types.optionSet;
|
||||
options = [ environOpts ];
|
||||
type = types.attrsOf (mkOptionType {
|
||||
name = "a string or a list of strings";
|
||||
check = x: builtins.isString x || isList x;
|
||||
});
|
||||
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
|
||||
};
|
||||
|
||||
environment.profiles = mkOption {
|
||||
|
@ -140,7 +112,7 @@ in
|
|||
environment.binsh = mkOption {
|
||||
default = "${config.system.build.binsh}/bin/sh";
|
||||
example = "\${pkgs.dash}/bin/dash";
|
||||
type = with pkgs.lib.types; path;
|
||||
type = types.path;
|
||||
description = ''
|
||||
The shell executable that is linked system-wide to
|
||||
<literal>/bin/sh</literal>. Please note that NixOS assumes all
|
||||
|
@ -177,7 +149,7 @@ in
|
|||
${concatStringsSep "\n" (
|
||||
(mapAttrsToList (n: v: ''export ${n}="${concatStringsSep ":" v}"'')
|
||||
# This line is a kind of a hack because of !!! note above
|
||||
(fold (mergeAttrsWithFunc concat) {} ([ (mapAttrs (n: v: [ v.value ]) cfg.variables) ] ++ map cfg.profileVariables cfg.profiles))))}
|
||||
(fold (mergeAttrsWithFunc concat) {} ([ (mapAttrs (n: v: [ v ]) cfg.variables) ] ++ map cfg.profileVariables cfg.profiles))))}
|
||||
|
||||
${cfg.extraInit}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ with pkgs.lib;
|
|||
|
||||
config = {
|
||||
|
||||
environment.variables.TZDIR.value = "/etc/zoneinfo";
|
||||
environment.variables.TZ.value = config.time.timeZone;
|
||||
environment.variables.TZDIR = "/etc/zoneinfo";
|
||||
environment.variables.TZ = config.time.timeZone;
|
||||
|
||||
environment.etc.localtime.source = "${pkgs.tzdata}/share/zoneinfo/${config.time.timeZone}";
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ with pkgs.lib;
|
|||
# Tell the Nix evaluator to garbage collect more aggressively.
|
||||
# This is desirable in memory-constrained environments that don't
|
||||
# (yet) have swap set up.
|
||||
environment.variables.GC_INITIAL_HEAP_SIZE.value = "100000";
|
||||
environment.variables.GC_INITIAL_HEAP_SIZE = "100000";
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,18 +17,18 @@ in
|
|||
config = {
|
||||
|
||||
environment.variables =
|
||||
{ LOCALE_ARCHIVE.value = "/run/current-system/sw/lib/locale/locale-archive";
|
||||
LOCATE_PATH.value = "/var/cache/locatedb";
|
||||
NIXPKGS_CONFIG.value = "/etc/nix/nixpkgs-config.nix";
|
||||
NIX_PATH.list =
|
||||
{ LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
|
||||
LOCATE_PATH = "/var/cache/locatedb";
|
||||
NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
|
||||
NIX_PATH =
|
||||
[ "/nix/var/nix/profiles/per-user/root/channels/nixos"
|
||||
"nixpkgs=/etc/nixos/nixpkgs"
|
||||
"nixos=/etc/nixos/nixos"
|
||||
"nixos-config=/etc/nixos/configuration.nix"
|
||||
"services=/etc/nixos/services"
|
||||
];
|
||||
PAGER.value = "less -R";
|
||||
EDITOR.value = "nano";
|
||||
PAGER = "less -R";
|
||||
EDITOR = "nano";
|
||||
};
|
||||
|
||||
environment.profiles =
|
||||
|
|
|
@ -17,9 +17,9 @@ with pkgs.lib;
|
|||
}
|
||||
];
|
||||
|
||||
environment.variables.OPENSSL_X509_CERT_FILE.value = "/etc/ssl/certs/ca-bundle.crt";
|
||||
environment.variables.CURL_CA_BUNDLE.value = "/etc/ssl/certs/ca-bundle.crt";
|
||||
environment.variables.GIT_SSL_CAINFO.value = "/etc/ssl/certs/ca-bundle.crt";
|
||||
environment.variables.OPENSSL_X509_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";
|
||||
environment.variables.CURL_CA_BUNDLE = "/etc/ssl/certs/ca-bundle.crt";
|
||||
environment.variables.GIT_SSL_CAINFO = "/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ in
|
|||
};
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
environment.variables = mapAttrs (n: v: { value = v; }) cfg.envVars;
|
||||
environment.variables = cfg.envVars;
|
||||
|
||||
environment.extraInit =
|
||||
''
|
||||
|
|
|
@ -79,7 +79,7 @@ in
|
|||
environment.pathsToLink =
|
||||
[ "/share/xfce4" "/share/themes" "/share/mime" "/share/desktop-directories" "/share/gtksourceview-2.0" ];
|
||||
|
||||
environment.variables.GIO_EXTRA_MODULES.value = "${pkgs.xfce.gvfs}/lib/gio/modules";
|
||||
environment.variables.GIO_EXTRA_MODULES = "${pkgs.xfce.gvfs}/lib/gio/modules";
|
||||
|
||||
# Enable helpful DBus services.
|
||||
services.udisks2.enable = true;
|
||||
|
|
|
@ -409,7 +409,7 @@ in
|
|||
boot.blacklistedKernelModules =
|
||||
optionals (elem "nvidia" driverNames) [ "nouveau" "nvidiafb" ];
|
||||
|
||||
environment.variables.LD_LIBRARY_PATH.list =
|
||||
environment.variables.LD_LIBRARY_PATH =
|
||||
[ "/run/opengl-driver/lib" "/run/opengl-driver-32/lib" ];
|
||||
|
||||
environment.etc =
|
||||
|
|
|
@ -105,7 +105,7 @@ with pkgs.lib;
|
|||
echo ${config.system.sbin.modprobe}/sbin/modprobe > /proc/sys/kernel/modprobe
|
||||
'';
|
||||
|
||||
environment.variables.MODULE_DIR.value = "/run/current-system/kernel-modules/lib/modules";
|
||||
environment.variables.MODULE_DIR = "/run/current-system/kernel-modules/lib/modules";
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue