Skip to content

Commit

Permalink
Add option to update remote before generating tag in nixpkgs
Browse files Browse the repository at this point in the history
Add config var: Remote name for upstream nixpkgs
  • Loading branch information
matthiasbeyer committed Oct 4, 2015
1 parent 31f574a commit e269335
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
7 changes: 7 additions & 0 deletions example.rc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ RC_SWITCH_DEFAULT_TAG_FLAGS="-a"
#
RC_SWITCH_DEFAULT_TAG_FLAGS_NIXPKGS=""


#
# The name of the remote in your nixpkgs clone which refers to the official
# repository of nixpkgs. Multiple entries must be seperated with space.
#
RC_SWITCH_UPSTREAM_NIXPKGS_REMOTE_NAME=upstream

#
# Container configuration templates can be put in single files and put in a
# directory which should be configured here.
Expand Down
37 changes: 35 additions & 2 deletions nix-script-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ usage() {
-p [<pkgs>] Generate the switch tag in the nixpkgs at <pkgs>
as well. (default: '$RC_NIXPKGS')
-r [<remote>] Update the <remote> in the <pkgs> before tagging.
Multiple possible, seperate with spaces.
Does nothing if -p is not passed.
(nixpkgs default: '$RC_NIXPKGS', remote default: '$RC_SWITCH_UPSTREAM_NIXPKGS_REMOTE_NAME')
-f <tag-flags> Flags for git-tag (see 'git tag --help')
(default: '$RC_SWITCH_DEFAULT_TAG_FLAGS')
Expand Down Expand Up @@ -57,7 +62,8 @@ $(help_rcvars \
"RC_CONFIG - Path of your system configuration (git) directory"\
"RC_NIXPKGS - Path of your nixpkgs clone" \
"RC_SWITCH_DEFAULT_TAG_FLAGS - Default git-tag flags for tagging in system configuration (git) directory"\
"RC_SWITCH_DEFAULT_TAG_FLAGS_NIXPKGS - Default git-tag flags for tagging in nixpkgs"
"RC_SWITCH_DEFAULT_TAG_FLAGS_NIXPKGS - Default git-tag flags for tagging in nixpkgs"\
"RC_SWITCH_UPSTREAM_NIXPKGS_REMOTE_NAME - Default git-remote name for the upstream nixpkgs"
)
$(help_end "${BASH_SOURCE[0]}")
Expand All @@ -73,11 +79,13 @@ TAG_NIXPKGS=0
NIXPKGS=$RC_NIXPKGS
TAG_FLAGS="$RC_SWITCH_DEFAULT_TAG_FLAGS"
TAG_FLAGS_NIXPKGS="$RC_SWITCH_DEFAULT_TAG_FLAGS_NIXPKGS"
DO_UPSTREAM_UPDATE=0
UPSTREAM_REMOTE="$RC_SWITCH_UPSTREAM_NIXPKGS_REMOTE_NAME"
DONT_BUILD=
QUIET=1
USE_ALTERNATIVE_SOURCE_NIXPKGS=0

while getopts "c:w:t:nbp:f:qs:h" OPTION
while getopts "c:w:t:nbp:f:qs:r:h" OPTION
do
case $OPTION in
c)
Expand Down Expand Up @@ -131,6 +139,17 @@ do
dbg "ALTERNATIVE_SOURCE_NIXPKGS = $ALTERNATIVE_SOURCE_NIXPKGS"
;;

r)
DO_UPSTREAM_UPDATE=1
if [[ -z "$OPTARG" ]]; then
dbg "Using default upstream"
else
UPSTREAM_REMOTE="$OPTARG"
fi
dbg "DO_UPSTREAM_UPDATE = $DO_UPSTREAM_UPDATE"
dbg "UPSTREAM_REMOTE = '$UPSTREAM_REMOTE'"
;;

h)
usage
exit 1
Expand Down Expand Up @@ -197,6 +216,20 @@ then

commit=$(nixos-version | cut -d . -f 3 | cut -d " " -f 1)

if [[ $DO_UPSTREAM_UPDATE -eq 1 ]]
then
dbg "Starting remote updating..."
for remote in $UPSTREAM_REMOTE
do
dbg "Updating remote '$remote'"
__git "$NIXPKGS" fetch "$remote"
dbg "Ready updating remote '$remote'"
done
dbg "... ready remote updating"
else
dbg "Not updating remote upstream here."
fi

continue_question "Trying to create tag '$TAG_NAME' at '$NIXPKGS' on commit '$commit'" && \
(__git "$NIXPKGS" tag $TAG_FLAGS_NIXPKGS "$TAG_NAME" $commit || \
stderr "Could not create tag in nixpkgs clone")
Expand Down

0 comments on commit e269335

Please sign in to comment.