6 , common-updater-scripts
9 # This is an updater for unstable packages that should always use the latest
11 { url ? null # The git url, if empty it will be set to src.gitRepoUrl
13 , stableVersion ? false # Use version format according to RFC 107 (i.e. LAST_TAG+date=YYYY-MM-DD)
14 , tagPrefix ? "" # strip this prefix from a tag name when using stable version
19 updateScript = writeShellScript "unstable-update-script.sh" ''
28 while (( $# > 0 )); do
42 tag_prefix="''${flag#*=}"
48 echo "$0: unknown option ‘''${flag}’"
54 # By default we set url to src.gitRepoUrl
55 if [[ -z "$url" ]]; then
56 url="$(${nix}/bin/nix-instantiate $systemArg --eval -E \
57 "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.gitRepoUrl" \
61 # Get info about HEAD from a shallow git clone
62 tmpdir="$(${coreutils}/bin/mktemp -d)"
68 if [[ "$shallow_clone" == "1" ]]; then
69 cloneArgs+=(--depth=1)
72 if [[ -n "$branch" ]]; then
73 cloneArgs+=(--branch="$branch")
76 ${git}/bin/git clone "''${cloneArgs[@]}" "$url" "$tmpdir"
79 commit_date="$(${git}/bin/git show -s --pretty='format:%cs')"
80 commit_sha="$(${git}/bin/git show -s --pretty='format:%H')"
81 if [[ -z "$use_stable_version" ]]; then
82 new_version="unstable-$commit_date"
85 while (( $depth < 10000 )); do
86 last_tag="$(${git}/bin/git describe --tags --abbrev=0 2> /dev/null || true)"
87 if [[ -n "$last_tag" ]]; then
90 ${git}/bin/git fetch --depth="$depth" --tags
91 depth=$(( $depth * 2 ))
93 if [[ -z "$last_tag" ]]; then
94 echo "Cound not found a tag within last 10000 commits" > /dev/stderr
97 if [[ -n "$tag_prefix" ]]; then
98 last_tag="''${last_tag#$tag_prefix}"
100 new_version="$last_tag+date=$commit_date"
103 # ${coreutils}/bin/rm -rf "$tmpdir"
105 # update the nix expression
106 ${common-updater-scripts}/bin/update-source-version \
107 "$UPDATE_NIX_ATTR_PATH" \
115 "--url=${builtins.toString url}"
116 ] ++ lib.optionals (branch != null) [
118 ] ++ lib.optionals stableVersion [
119 "--use-stable-version"
120 "--tag-prefix=${tagPrefix}"
121 ] ++ lib.optionals shallowClone [