Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 50 additions & 40 deletions home-manager/home-manager
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ function doBuildAttr() {
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
}

function doBuildFlake() {
local extraArgs=("$@")

if [[ -v VERBOSE ]]; then
extraArgs=("${extraArgs[@]}" "--verbose")
fi

nix build \
"${extraArgs[@]}" \
"${PASSTHROUGH_OPTS[@]}"
}

# Presents news to the user. Takes as argument the path to a "news
# info" file as generated by `buildNews`.
function presentNews() {
Expand Down Expand Up @@ -246,43 +258,31 @@ function doBuild() {
return 1
fi

setWorkDir

setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
nix build \
"${PASSTHROUGH_OPTS[@]}" \
${DRY_RUN+--dry-run} \
${NO_OUT_LINK+--no-link} \
doBuildFlake \
"${DRY_RUN+--dry-run} \
"${NO_OUT_LINK+--no-link} \
"$FLAKE_CONFIG_URI.activationPackage" \
|| return
fi

setWorkDir

local newsInfo
newsInfo=$(buildNews)

doBuildAttr \
${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \
else
doBuildAttr \
${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \
|| return

presentNews "$newsInfo"
}
local newsInfo
newsInfo=$(buildNews)

function doSwitch() {
setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
nix run \
"${PASSTHROUGH_OPTS[@]}" \
"$FLAKE_CONFIG_URI.activationPackage" \
|| return
presentNews "$newsInfo"
fi
}

function doSwitch() {
setWorkDir

local newsInfo
newsInfo=$(buildNews)

local generation

# Build the generation and run the activate script. Note, we
Expand All @@ -291,12 +291,23 @@ function doSwitch() {
# before activation completes.
generation="$WORK_DIR/generation"

doBuildAttr \
--out-link "$generation" \
--attr activationPackage \
&& "$generation/activate" || return
setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
doBuildFlake \
--out-link "$generation" \
"$FLAKE_CONFIG_URI.activationPackage" \
&& "$generation/activate" || return
else
doBuildAttr \
--out-link "$generation" \
--attr activationPackage \
&& "$generation/activate" || return

presentNews "$newsInfo"
local newsInfo
newsInfo=$(buildNews)

presentNews "$newsInfo"
fi
}

function doListGens() {
Expand Down Expand Up @@ -393,13 +404,13 @@ function buildNews() {
output="$WORK_DIR/news-info.sh"

doBuildAttr \
--out-link "$output" \
--no-build-output \
--quiet \
--arg check false \
--argstr newsReadIdsFile "$(newsReadIdsFile)" \
--attr newsInfo \
> /dev/null
--out-link "$output" \
--no-build-output \
--quiet \
--arg check false \
--argstr newsReadIdsFile "$(newsReadIdsFile)" \
--attr newsInfo \
> /dev/null

echo "$output"
}
Expand Down Expand Up @@ -616,8 +627,7 @@ while [[ $# -gt 0 ]]; do
shift
;;
--debug|--keep-failed|--keep-going|--show-trace\
|--substitute|--no-substitute|--impure\
|--no-write-lock-file)
Comment thread
berbiche marked this conversation as resolved.
|--substitute|--no-substitute|--impure)
PASSTHROUGH_OPTS+=("$opt")
;;
-v|--verbose)
Expand Down