mirror of
https://github.com/nix-community/home-manager
synced 2025-01-23 01:19:52 +01:00
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
This commit is contained in:
parent
7fa890462d
commit
5969551a5c
3 changed files with 43 additions and 2 deletions
|
@ -17,6 +17,10 @@
|
||||||
build
|
build
|
||||||
</arg>
|
</arg>
|
||||||
|
|
||||||
|
<arg choice="plain">
|
||||||
|
instantiate
|
||||||
|
</arg>
|
||||||
|
|
||||||
<arg choice="plain">
|
<arg choice="plain">
|
||||||
edit
|
edit
|
||||||
</arg>
|
</arg>
|
||||||
|
@ -163,6 +167,16 @@
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>instantiate</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Instantiate the configuration and print the resulting derivation.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>edit</option>
|
<option>edit</option>
|
||||||
|
|
|
@ -278,7 +278,7 @@ _home-manager_completions ()
|
||||||
#--------------------------#
|
#--------------------------#
|
||||||
|
|
||||||
local Subcommands
|
local Subcommands
|
||||||
Subcommands=( "help" "edit" "build" "switch" "generations" "remove-generations" "expire-generations" "packages" "news" "uninstall" )
|
Subcommands=( "help" "edit" "build" "instantiate" "switch" "generations" "remove-generations" "expire-generations" "packages" "news" "uninstall" )
|
||||||
|
|
||||||
# ^ « home-manager »'s subcommands.
|
# ^ « home-manager »'s subcommands.
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,28 @@ function setHomeManagerNixPath() {
|
||||||
done
|
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() {
|
function doBuildAttr() {
|
||||||
setConfigFile
|
setConfigFile
|
||||||
setHomeManagerNixPath
|
setHomeManagerNixPath
|
||||||
|
@ -441,6 +463,8 @@ function doHelp() {
|
||||||
echo
|
echo
|
||||||
echo " build Build configuration into result directory"
|
echo " build Build configuration into result directory"
|
||||||
echo
|
echo
|
||||||
|
echo " instantiate Instantiate the configuration and print the resulting derivation"
|
||||||
|
echo
|
||||||
echo " switch Build and activate configuration"
|
echo " switch Build and activate configuration"
|
||||||
echo
|
echo
|
||||||
echo " generations List all home environment generations"
|
echo " generations List all home environment generations"
|
||||||
|
@ -471,7 +495,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
opt="$1"
|
opt="$1"
|
||||||
shift
|
shift
|
||||||
case $opt in
|
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"
|
COMMAND="$opt"
|
||||||
;;
|
;;
|
||||||
-2)
|
-2)
|
||||||
|
@ -542,6 +566,9 @@ case $COMMAND in
|
||||||
build)
|
build)
|
||||||
doBuild
|
doBuild
|
||||||
;;
|
;;
|
||||||
|
instantiate)
|
||||||
|
doInstantiate
|
||||||
|
;;
|
||||||
switch)
|
switch)
|
||||||
doSwitch
|
doSwitch
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue