From 9df40867b98ff21af499cb423fd758e351188e6b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 23 Sep 2013 23:03:21 +0200 Subject: [PATCH] In environment.variables, unify "value" and "list" --- modules/config/fonts/fontconfig.nix | 2 +- modules/config/i18n.nix | 2 +- modules/config/shells-environment.nix | 48 ++++--------------- modules/config/timezone.nix | 4 +- modules/profiles/installation-device.nix | 2 +- modules/programs/environment.nix | 12 ++--- modules/security/ca.nix | 6 +-- modules/services/misc/nix-daemon.nix | 2 +- .../services/x11/desktop-managers/xfce.nix | 2 +- modules/services/x11/xserver.nix | 2 +- modules/system/boot/modprobe.nix | 2 +- 11 files changed, 28 insertions(+), 56 deletions(-) diff --git a/modules/config/fonts/fontconfig.nix b/modules/config/fonts/fontconfig.nix index 88643b41d838..6e0fdaf4b748 100644 --- a/modules/config/fonts/fontconfig.nix +++ b/modules/config/fonts/fontconfig.nix @@ -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 ]; diff --git a/modules/config/i18n.nix b/modules/config/i18n.nix index 15df0b3a12aa..c3e39717258b 100644 --- a/modules/config/i18n.nix +++ b/modules/config/i18n.nix @@ -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 diff --git a/modules/config/shells-environment.nix b/modules/config/shells-environment.nix index 116c5f11e1f2..4ee80b39fa30 100644 --- a/modules/config/shells-environment.nix +++ b/modules/config/shells-environment.nix @@ -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 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 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 /bin/sh. 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} diff --git a/modules/config/timezone.nix b/modules/config/timezone.nix index 68b785601faf..e185584846a7 100644 --- a/modules/config/timezone.nix +++ b/modules/config/timezone.nix @@ -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}"; diff --git a/modules/profiles/installation-device.nix b/modules/profiles/installation-device.nix index cfb2eb3f9cb1..3b058c6e9715 100644 --- a/modules/profiles/installation-device.nix +++ b/modules/profiles/installation-device.nix @@ -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"; }; } diff --git a/modules/programs/environment.nix b/modules/programs/environment.nix index 8f2df7e4a531..f42df3514221 100644 --- a/modules/programs/environment.nix +++ b/modules/programs/environment.nix @@ -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 = diff --git a/modules/security/ca.nix b/modules/security/ca.nix index f0897630eac7..2e93fb36b450 100644 --- a/modules/security/ca.nix +++ b/modules/security/ca.nix @@ -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"; }; diff --git a/modules/services/misc/nix-daemon.nix b/modules/services/misc/nix-daemon.nix index 9dd58fbab20a..adf4f145f25d 100644 --- a/modules/services/misc/nix-daemon.nix +++ b/modules/services/misc/nix-daemon.nix @@ -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 = '' diff --git a/modules/services/x11/desktop-managers/xfce.nix b/modules/services/x11/desktop-managers/xfce.nix index 6197a7e10aa7..f5d544ad0462 100644 --- a/modules/services/x11/desktop-managers/xfce.nix +++ b/modules/services/x11/desktop-managers/xfce.nix @@ -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; diff --git a/modules/services/x11/xserver.nix b/modules/services/x11/xserver.nix index 2c76361ea4bf..5a9a2e8df4d7 100644 --- a/modules/services/x11/xserver.nix +++ b/modules/services/x11/xserver.nix @@ -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 = diff --git a/modules/system/boot/modprobe.nix b/modules/system/boot/modprobe.nix index c1c65bed64f4..8b2762e2526d 100644 --- a/modules/system/boot/modprobe.nix +++ b/modules/system/boot/modprobe.nix @@ -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"; };