aboutsummaryrefslogtreecommitdiff
path: root/home-manager/home-manager
diff options
context:
space:
mode:
authorTimo Kaufmann <timokau@zoho.com>2020-03-18 00:02:38 +0100
committerRobert Helgesson <robert@rycee.net>2020-03-25 21:16:43 +0100
commit5969551a5cc52f9470b5ff5ca01327bf4bda82c1 (patch)
tree3491c64a35d8532c855a6b633ae5c6d960128093 /home-manager/home-manager
parent7fa890462d2105566cc36599833cb3cb153df0ed (diff)
home-manager: add instantiate subcommand
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. PR #1099
Diffstat (limited to 'home-manager/home-manager')
-rw-r--r--home-manager/home-manager29
1 files changed, 28 insertions, 1 deletions
diff --git a/home-manager/home-manager b/home-manager/home-manager
index 7fa5c35c300..f7436e3e290 100644
--- a/home-manager/home-manager
+++ b/home-manager/home-manager
@@ -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
@@ -441,6 +463,8 @@ function doHelp() {
echo
echo " build Build configuration into result directory"
echo
+ echo " instantiate Instantiate the configuration and print the resulting derivation"
+ echo
echo " switch Build and activate configuration"
echo
echo " generations List all home environment generations"
@@ -471,7 +495,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)
@@ -542,6 +566,9 @@ case $COMMAND in
build)
doBuild
;;
+ instantiate)
+ doInstantiate
+ ;;
switch)
doSwitch
;;