Skip to content

Commit

Permalink
Add home-manager instantiate subcommand
Browse files Browse the repository at this point in the history
It can be useful to simply instantiate a home-manager configuration
without actually building it, for example for the purpose of
pre-building it with some custom command.
  • Loading branch information
timokau committed Mar 23, 2020
1 parent 5c1e734 commit 64c9f87
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion home-manager/home-manager
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ function setHomeManagerNixPath() {
done
}

function doInstantiate() {
setConfigFile
setHomeManagerNixPath

local extraArgs=("$@")

for p in "${EXTRA_NIX_PATH[@]}"; do
extraArgs=("${extraArgs[@]}" "-I" "$p")
done

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

nix-instantiate \
"<home-manager/home-manager/home-manager.nix>" \
"${extraArgs[@]}" \
"${PASSTHROUGH_OPTS[@]}" \
--argstr confPath "$HOME_MANAGER_CONFIG" \
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
}

function doBuildAttr() {
setConfigFile
setHomeManagerNixPath
Expand Down Expand Up @@ -471,7 +493,7 @@ while [[ $# -gt 0 ]]; do
opt="$1"
shift
case $opt in
build|edit|expire-generations|generations|help|news|packages|remove-generations|switch|uninstall)
build|instantiate|edit|expire-generations|generations|help|news|packages|remove-generations|switch|uninstall)
COMMAND="$opt"
;;
-2)
Expand Down Expand Up @@ -542,6 +564,9 @@ case $COMMAND in
build)
doBuild
;;
instantiate)
doInstantiate
;;
switch)
doSwitch
;;
Expand Down

0 comments on commit 64c9f87

Please sign in to comment.