1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-16 11:38:31 +02:00
home-manager/home-manager/home-manager

70 lines
1.6 KiB
Plaintext
Raw Normal View History

2017-01-07 19:16:26 +01:00
#!@bash@/bin/bash
function doRebuild() {
if [[ -z "$1" ]] ; then
echo "Need to provide path to configuration file."
exit 1
fi
local confFile
confFile="$(realpath "$1")"
2017-01-07 19:16:26 +01:00
local wrkdir
wrkdir="$(mktemp -d)"
nix-build --show-trace \
"@HOME_MANAGER_EXPR_PATH@" \
--argstr modulesPath "$HOME/.nixpkgs/home-manager/modules" \
--argstr confPath "$confFile" \
2017-01-07 19:16:26 +01:00
-A activation-script \
-o "$wrkdir/activate"
"$wrkdir/activate/libexec/home-activate"
rm -rv "$wrkdir"
}
function doListGens() {
ls --color=yes -gG --sort time "/nix/var/nix/gcroots/per-user/$(whoami)" \
| cut -d' ' -f 4-
}
function doListPackages() {
local outPath
outPath="$(nix-env -q --out-path | grep -o '/.*home-manager-path$')"
if [[ -n "$outPath" ]] ; then
nix-store -q --references "$outPath" | sed 's/[^-]*-//'
else
echo "No home-manager packages seem to be installed."
fi
2017-01-07 19:16:26 +01:00
}
function doHelp() {
echo "Usage: $0 {help | rebuild CONF | generations | packages}"
echo
echo "Commands"
echo " help Print this help"
echo " rebuild Rebuild the current environment"
echo " generations List all home environment generations"
echo " packages List all packages installed in home-manager-path"
}
case $1 in
rebuild)
doRebuild "$2"
;;
generations)
doListGens
;;
packages)
doListPackages
;;
help|--help)
doHelp
;;
*)
echo "Unknown command: $1"
doHelp
exit 1
esac