1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-18 04:28:32 +02:00
home-manager/home-manager/home-manager
Robert Helgesson d7d02c3ce8
Initial import
2017-01-14 13:15:24 +01:00

63 lines
1.4 KiB
Bash

#!@bash@/bin/bash
function doRebuild() {
if [[ -z "$1" ]] ; then
echo "Need to provide path to configuration file."
exit 1
fi
local wrkdir
wrkdir="$(mktemp -d)"
nix-build --show-trace \
"@HOME_MANAGER_EXPR_PATH@" \
--argstr modulesPath "$HOME/.nixpkgs/home-manager/modules" \
--argstr confPath "$1" \
-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$')"
nix-store -q --references "$outPath" | sed 's/[^-]*-//'
}
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