summaryrefslogtreecommitdiffstats
path: root/nix-script-show-generation.sh
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-09-07 19:06:23 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-09-07 19:06:23 +0200
commitd4a25befed94859785b08acc58dc046c0246948d (patch)
tree6aa9159442591fb1d69209695d63507b6dcbc868 /nix-script-show-generation.sh
parent4dcf630cbc02cc1ce408ec9206c41bb8ee7a4d56 (diff)
show-generation: Support for showing generation of custom profile
Diffstat (limited to 'nix-script-show-generation.sh')
-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"