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
18 updateScript = writeShellScript "unstable-update-script.sh" ''
26 while (( $# > 0 )); do
40 tag_prefix="''${flag#*=}"
43 echo "$0: unknown option ‘''${flag}’"
49 # By default we set url to src.gitRepoUrl
50 if [[ -z "$url" ]]; then
51 url="$(${nix}/bin/nix-instantiate $systemArg --eval -E \
52 "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.gitRepoUrl" \
56 # Get info about HEAD from a shallow git clone
57 tmpdir="$(${coreutils}/bin/mktemp -d)"
64 if [[ -n "$branch" ]]; then
65 cloneArgs+=(--branch="$branch")
68 ${git}/bin/git clone "''${cloneArgs[@]}" "$url" "$tmpdir"
71 commit_date="$(${git}/bin/git show -s --pretty='format:%cs')"
72 commit_sha="$(${git}/bin/git show -s --pretty='format:%H')"
73 if [[ -z "$use_stable_version" ]]; then
74 new_version="unstable-$commit_date"
77 while (( $depth < 10000 )); do
78 last_tag="$(${git}/bin/git describe --tags --abbrev=0 2> /dev/null || true)"
79 if [[ -n "$last_tag" ]]; then
82 ${git}/bin/git fetch --depth="$depth" --tags
83 depth=$(( $depth * 2 ))
85 if [[ -z "$last_tag" ]]; then
86 echo "Cound not found a tag within last 10000 commits" > /dev/stderr
89 if [[ -n "$tag_prefix" ]]; then
90 last_tag="''${last_tag#$tag_prefix}"
92 new_version="$last_tag+date=$commit_date"
95 # ${coreutils}/bin/rm -rf "$tmpdir"
97 # update the nix expression
98 ${common-updater-scripts}/bin/update-source-version \
99 "$UPDATE_NIX_ATTR_PATH" \
106 "--url=${builtins.toString url}"
107 ] ++ lib.optionals (branch != null) [
109 ] ++ lib.optionals stableVersion [
110 "--use-stable-version"
111 "--tag-prefix=${tagPrefix}"