From b95ad632010bf1d135f7585c590f51f6c3dc2896 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 24 May 2020 18:08:49 +0200 Subject: [PATCH] Deprecate use of `builtins.getEnv` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the use of the non-deterministic function `builtins.getEnv` for state version ≥ 20.09. PR #1269 --- doc/release-notes/rl-2009.adoc | 26 +++++++++++++++++++++++++- home-manager/install.nix | 19 ++++++++++++++++++- modules/home-environment.nix | 22 +++++++++++++++++----- modules/misc/xdg.nix | 10 +++++++++- 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/doc/release-notes/rl-2009.adoc b/doc/release-notes/rl-2009.adoc index 96dfce930..0562e046d 100644 --- a/doc/release-notes/rl-2009.adoc +++ b/doc/release-notes/rl-2009.adoc @@ -18,4 +18,28 @@ The state version in this release includes the changes below. These changes are only active if the `home.stateVersion` option is set to "20.09" or later. -* Nothing has happened. +* The options <> and <> no +longer have default values and must therefore be provided in your +configuration. Previously their values would default to the content of +the environment variables `HOME` and `USER`, respectively. ++ +-- +Further, the options <>, <>, +and <> will no longer be affected by the +`XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, and `XDG_DATA_HOME` environment +variables. They now unconditionally default to + +- `"${config.home.homeDirectory}/.cache"`, +- `"${config.home.homeDirectory}/.config"`, and +- `"${config.home.homeDirectory}/.local/share"`. + +If you choose to switch to state version 20.09 then you must set these +options if you use non-default XDG base directory paths. + +The initial configuration generated by + +[source,console] +$ nix-shell '' -A install + +will automatically include these options, when necessary. +-- diff --git a/home-manager/install.nix b/home-manager/install.nix index 92de17bd6..87252730e 100644 --- a/home-manager/install.nix +++ b/home-manager/install.nix @@ -12,6 +12,18 @@ runCommand "home-manager-install" { echo echo "Creating initial Home Manager configuration..." + nl=$'\n' + xdgVars="" + if [[ -v XDG_CACHE_HOME && $XDG_CACHE_HOME != "$HOME/.cache" ]]; then + xdgVars="$xdgVars xdg.cacheHome = \"$XDG_CACHE_HOME\";$nl" + fi + if [[ -v XDG_CONFIG_HOME && $XDG_CONFIG_HOME != "$HOME/.config" ]]; then + xdgVars="$xdgVars xdg.configHome = \"$XDG_CONFIG_HOME\";$nl" + fi + if [[ -v XDG_DATA_HOME && $XDG_DATA_HOME != "$HOME/.local/share" ]]; then + xdgVars="$xdgVars xdg.dataHome = \"$XDG_DATA_HOME\";$nl" + fi + mkdir -p "$(dirname "$confFile")" cat > $confFile <