summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-09-12 17:23:31 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-09-12 17:23:31 +0200
commitb0d8860dc9f78180f3f3e210bec9e955e4143bf6 (patch)
tree5c20708447895b9e8328e2d55bb5c3688ded7173
parentbb8e24cb3936df895aedd4418c2841a03a9bb58d (diff)
parentd4a25befed94859785b08acc58dc046c0246948d (diff)
Merge pull request #75 from matthiasbeyer/show-profile-gen
show-generation: Support for showing generation of custom profile
-rwxr-xr-xnix-script-show-generation.sh28
1 files changed, 22 insertions, 6 deletions
diff --git a/nix-script-show-generation.sh b/nix-script-show-generation.sh
index 27320ad..60216c6 100755
--- a/nix-script-show-generation.sh
+++ b/nix-script-show-generation.sh
@@ -4,11 +4,12 @@ source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh
usage() {
cat <<EOS
- $(help_synopsis "${BASH_SOURCE[0]}" "[-s | -u] [-h]")
+ $(help_synopsis "${BASH_SOURCE[0]}" "[-s | -u | -p <profile>] [-h]")
- -s Show system generation
- -u Show user generation (default)
- -h Show this help and exit
+ -s | Show system generation
+ -u | Show user generation (default)
+ -p <profile> | Show <profile> generation
+ -h | Show this help and exit
Show the number of the current generations. Defaults to user
profile, but system profile can be checked as well.
@@ -25,8 +26,9 @@ EOS
SYSTEM=0
USER=1
+PROFILE=""
-while getopts "suh" OPTION
+while getopts "sup:h" OPTION
do
case $OPTION in
s)
@@ -39,6 +41,13 @@ do
USER=1
stdout "Showing user generation"
;;
+ p)
+ SYSTEM=0
+ USER=0
+ PROFILE=$OPTARG
+ dbg "PROFILE = $PROFILE"
+ ;;
+
h)
stdout "Showing usage"
usage
@@ -47,7 +56,14 @@ do
esac
done
-([[ $SYSTEM -eq 1 ]] && current_system_generation) || current_user_generation
+if [[ ! -z "$PROFILE" ]]
+then
+ grep_generation "sudo nix-env -p /nix/var/nix/profiles/$PROFILE --list-generations"
+else
+ ([[ $SYSTEM -eq 1 ]] && current_system_generation) || \
+ current_user_generation
+fi
+
stdout "Ready"