summaryrefslogtreecommitdiffstats
path: root/update.sh
diff options
context:
space:
mode:
authorCole Mickens <cole.mickens@gmail.com>2018-10-24 06:27:38 -0700
committerCole Mickens <cole.mickens@gmail.com>2018-10-24 06:37:21 -0700
commitdfee4fa635d29a3a761e70a3a1140f8221ea3861 (patch)
tree87d183c20fe1b1cc3b0a0f38c8d3e9ef980e06cd /update.sh
parent18a8b5f39af2090a1bec9a9b8f705f7c1db6ac03 (diff)
update.sh: fixup github api usage
Diffstat (limited to 'update.sh')
-rwxr-xr-xupdate.sh12
1 files changed, 3 insertions, 9 deletions
diff --git a/update.sh b/update.sh
index f7d60e1..572b6a1 100755
--- a/update.sh
+++ b/update.sh
@@ -2,17 +2,11 @@
set -euo pipefail
set -x
-##
-## use github api to get latest commit for a repo
-## use nix-prefetch-url to get the hash
-## update files in place with `update-source-version`
-##
-
export nixpkgs=/etc/nixpkgs-sway
export NIX_PATH=nixpkgs=${nixpkgs}
-# TODO: ew
-token="$(cat /etc/nixos/secrets/github-colebot-token)"
+GHUSER="${GHUSER:-"$(cat /etc/nixos/secrets/github-username)"}"
+GHPASS="${GHPASS:-"$(cat /etc/nixos/secrets/github-token)"}"
# update: <derivation-name> <github-repo-owner> <github-repo-name> <ref>
function update() {
@@ -20,7 +14,7 @@ function update() {
owner="${2}"
repo="${3}"
ref="${4}"
- rev="$(curl -u colebot:$token --silent --fail "https://api.github.com/repos/${owner}/${repo}/commits?sha=${ref}" | jq -r ".[0].sha")"
+ rev="$(curl -u "${GHUSER}:${GHPASS}" --silent --fail "https://api.github.com/repos/${owner}/${repo}/commits?sha=${ref}" | jq -r ".[0].sha")"
sha256="$(nix-prefetch-url --unpack "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz" 2>/dev/null)"
mkdir -p "./${attr}"