blob: 4ad8720ddb2879392c37a8e081b858427b3ab6c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/usr/bin/env bash
source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh
[[ -f "$RC" ]] && { dbg "Config file found. Sourcing: '$RC'"; source $RC; }
usage() {
cat <<EOS
$(help_synopsis "channel" "update [-h] [-t <name>] [-w <cfgdir>] [-n]")
-t <name> | Name for the new tag, instead of nixos-<host>-channel-<num>
-n | Add channel name (from config) in the tag name, currently: $RC_CHANNEL_NAME
-w <cfgdir> | Alternative config dir, default: $RC_CONFIG
-n | DON'T include hostname in tag name
-h | Show this help and exit
$(help_end)
EOS
}
TAG_NAME=""
ADD_CHANNEL_NAME=0
CONFIG=$RC_CONFIG
HOST="$(hostname)"
while getopts "t:w:nh" OPTION
do
case $OPTION in
t)
TAG_NAME=$OPTARG
dbg "TAG_NAME = $TAG_NAME"
;;
n)
ADD_CHANNEL_NAME=1
dbg "ADD_CHANNEL_NAME = $ADD_CHANNEL_NAME"
;;
w)
CONFIG=$OPTARG
dbg "CONFIG = $CONFIG"
;;
n)
HOST=""
dbg "HOST = $HOST"
;;
h)
usage
exit 0
;;
*)
;;
esac
done
[[ -z "$CONFIG" ]] && \
stderr "No configuration git directory." && \
stderr "Won't do anything" && exit 1
stdout "Updating nix-channel"
explain sudo nix-channel --update
stdout "Ready with updating"
if [[ -z "$NAME" ]]
then
TAG_NAME="nixos-$([[ ! -z "$HOST" ]] && echo "$HOST-")channel-$(current_channel_generation)"
stdout "Tag name: '$TAG_NAME'"
fi
if [[ $ADD_CHANNEL_NAME -eq 1 ]]; then
[[ -z "$RC_CHANNEL_NAME" ]] && \
stderr "RC SETTING MISSING: RC_CHANNEL_NAME" && exit 1
dbg "Add the channel name in the tag"
TAG_NAME="${TAG_NAME}-${RC_CHANNEL_NAME}"
dbg "TAG_NAME = ${TAG_NAME}"
else
dbg "Do not add the channel name in the tag"
fi
stdout "Resetting sudo password"
sudo -k
stdout "Tagging '$CONFIG' repo with tag name '$TAG_NAME'"
__git "$CONFIG" tag $TAG_NAME
|