summaryrefslogtreecommitdiffstatshomepage
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/with-github-auth.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/nix/with-github-auth.sh b/nix/with-github-auth.sh
new file mode 100644
index 0000000..8b7002a
--- /dev/null
+++ b/nix/with-github-auth.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+set -eu
+
+if command -v gh >/dev/null 2>&1 && github_token=$(gh auth token --hostname github.com 2>/dev/null); then
+ NIX_CONFIG="${NIX_CONFIG:-}
+extra-access-tokens = github.com=$github_token"
+ export NIX_CONFIG
+ unset github_token
+fi
+
+exec "$@"