From 2245b0ac94978c259bb054b49f0e45433af411c4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 12:55:30 +0200 Subject: [PATCH] home-manager: simplify use of nix-build output There is no need to specify an out link when switching to a new generation since nix-build prints the store path on standard output. Similarly, when just building a generation we specify no out link since nix-build will use "result" by default. --- home-manager/home-manager | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 45fe0e1cb..1874143ad 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -49,27 +49,11 @@ function setHomeManagerModulesPath() { } function doBuild() { - if [[ -z "$1" ]]; then - echo "Need to provide generation output path." - exit 1 - fi - - if [[ -e "$1" ]]; then - echo "The output path $1 already exists." - exit 1 - fi - setConfigFile setHomeManagerModulesPath - output="$(realpath "$1")" - - if [[ $? -ne 0 ]]; then - exit 1 - fi - local extraArgs - extraArgs="" + extraArgs="$1" for p in "${EXTRA_NIX_PATH[@]}"; do extraArgs="$extraArgs -I $p" @@ -83,21 +67,15 @@ function doBuild() { "@HOME_MANAGER_EXPR_PATH@" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" \ - -A activation-script \ - -o "$output" + -A activation-script } function doSwitch() { - local wrkdir - wrkdir="$(mktemp -d)" - local generation local exitCode=0 - generation=$(doBuild "$wrkdir/result") && $generation/activate || exitCode=1 - # Because the previous command never fails, the script keeps running and - # $wrkdir is always removed. - rm -r "$wrkdir" + generation=$(doBuild "--no-out-link") && $generation/activate || exitCode=1 + return $exitCode } @@ -179,7 +157,7 @@ cmd="$*" case "$cmd" in build) - doBuild "result" + doBuild "" ;; switch) doSwitch