From 9ab59dd6ac4422d99093b56dc3b9ab1044c4d12d Mon Sep 17 00:00:00 2001 From: Chris Hodapp <108633+clhodapp@users.noreply.github.com> Date: Sun, 23 Feb 2020 02:37:03 -0800 Subject: [PATCH] home-manager: handle args with spaces to doBuildAttr Presently, if you pass an argument with spaces in it to `doBuildAttr`, it will be split it into multiple arguments to `nix build` or `nix-build`. This situation arises, for example, on systems with spaces in `XDG_DATA_HOME`. Specifically, the `home-manager` script errors out in trying to address the `read-news` state file. With this change, argument separation should be preserved properly in `doBuildAttr`. PR #1044 --- home-manager/home-manager | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index b0821dfa..7fa5c35c 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -78,28 +78,28 @@ function doBuildAttr() { setConfigFile setHomeManagerNixPath - local extraArgs="$*" + local extraArgs=("$@") for p in "${EXTRA_NIX_PATH[@]}"; do - extraArgs="$extraArgs -I $p" + extraArgs=("${extraArgs[@]}" "-I" "$p") done if [[ -v VERBOSE ]]; then - extraArgs="$extraArgs --show-trace" + extraArgs=("${extraArgs[@]}" "--show-trace") fi # shellcheck disable=2086 if [[ -v USE_NIX2_COMMAND ]]; then nix build \ -f "" \ - $extraArgs \ + "${extraArgs[@]}" \ "${PASSTHROUGH_OPTS[@]}" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" else nix-build \ "" \ - $extraArgs \ + "${extraArgs[@]}" \ "${PASSTHROUGH_OPTS[@]}" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"