diff options
author | Jan Tojnar <jtojnar@gmail.com> | 2022-02-18 08:12:44 +0100 |
---|---|---|
committer | Jan Tojnar <jtojnar@gmail.com> | 2022-02-18 17:26:45 +0100 |
commit | 3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45 (patch) | |
tree | ffaeb1cf0e7c52d8e0d5b386e1bc185ee9c74843 /pkgs/common-updater | |
parent | 30ec84fba39777e7e0af7352d89ba1271e5cf45e (diff) | |
download | nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.tar nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.tar.gz nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.tar.bz2 nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.tar.lz nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.tar.xz nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.tar.zst nixpkgs-3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45.zip |
unstableGitUpdater: Use single derivation for all branches
This will reduce the number of build when updating a large number of packages at the same time (e.g. when updating all packages of a maintainer).
Diffstat (limited to 'pkgs/common-updater')
-rw-r--r-- | pkgs/common-updater/unstable-updater.nix | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/pkgs/common-updater/unstable-updater.nix b/pkgs/common-updater/unstable-updater.nix index ded31e1ddb9..96683409371 100644 --- a/pkgs/common-updater/unstable-updater.nix +++ b/pkgs/common-updater/unstable-updater.nix @@ -16,7 +16,25 @@ let updateScript = writeShellScript "unstable-update-script.sh" '' set -ex - url="$1" + url="" + branch="" + + while (( $# > 0 )); do + flag="$1" + shift 1 + case "$flag" in + --url=*) + url="''${flag#*=}" + ;; + --branch=*) + branch="''${flag#*=}" + ;; + *) + echo "$0: unknown option ‘''${flag}’" + exit 1 + ;; + esac + done # By default we set url to src.url if [[ -z "$url" ]]; then @@ -27,9 +45,18 @@ let # Get info about HEAD from a shallow git clone tmpdir="$(${coreutils}/bin/mktemp -d)" - ${git}/bin/git clone --bare --depth=1 \ - ${lib.optionalString (branch != null) "--branch ${branch}"} \ - "$url" "$tmpdir" + + cloneArgs=( + --bare + --depth=1 + ) + + if [[ -n "$branch" ]]; then + cloneArgs+=(--branch="$branch") + fi + + ${git}/bin/git clone "''${cloneArgs[@]}" "$url" "$tmpdir" + pushd "$tmpdir" commit_date="$(${git}/bin/git show -s --pretty='format:%cs')" commit_sha="$(${git}/bin/git show -s --pretty='format:%H')" @@ -43,5 +70,10 @@ let --rev="$commit_sha" ''; -in [ updateScript url ] +in [ + updateScript + "--url=${builtins.toString url}" +] ++ lib.optionals (branch != null) [ + "--branch=${branch}" +] |