1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

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
This commit is contained in:
Chris Hodapp 2020-02-23 02:37:03 -08:00 committed by Robert Helgesson
parent 9ab4e70d17
commit 9ab59dd6ac
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -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 "<home-manager/home-manager/home-manager.nix>" \
$extraArgs \
"${extraArgs[@]}" \
"${PASSTHROUGH_OPTS[@]}" \
--argstr confPath "$HOME_MANAGER_CONFIG" \
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
else
nix-build \
"<home-manager/home-manager/home-manager.nix>" \
$extraArgs \
"${extraArgs[@]}" \
"${PASSTHROUGH_OPTS[@]}" \
--argstr confPath "$HOME_MANAGER_CONFIG" \
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"