diff options
| author | sommerfeld <sommerfeld@sommerfeld.dev> | 2026-09-17 15:05:36 +0100 |
|---|---|---|
| committer | sommerfeld <sommerfeld@sommerfeld.dev> | 2026-09-17 15:05:36 +0100 |
| commit | a7f74c1fa4b89c5829f5896842eb7248c820704c (patch) | |
| tree | e7f3c751d491a18c8cfc40455c49c23ea22f058b | |
| parent | 64d47934715959c6d52172c68ac6f15d1cb0b954 (diff) | |
| download | dotfiles-a7f74c1fa4b89c5829f5896842eb7248c820704c.tar.gz dotfiles-a7f74c1fa4b89c5829f5896842eb7248c820704c.tar.bz2 dotfiles-a7f74c1fa4b89c5829f5896842eb7248c820704c.zip | |
Use GitHub credentials for Nix when available
| -rw-r--r-- | justfile | 6 | ||||
| -rw-r--r-- | nix/with-github-auth.sh | 11 |
2 files changed, 15 insertions, 2 deletions
@@ -39,7 +39,8 @@ nix-switch: case "${ID:-}" in ubuntu|debian) profile=vm ;; esac - nix --extra-experimental-features 'nix-command flakes' \ + sh "{{ justfile_directory() }}/nix/with-github-auth.sh" \ + nix --extra-experimental-features 'nix-command flakes' \ run home-manager/master -- \ switch --impure --flake "{{ justfile_directory() }}/nix#${profile}" -b backup # Keep the login shell pointed at the Home-Manager-managed zsh. @@ -88,7 +89,8 @@ _nix-flake-update: echo "nix not installed; skipping flake update" >&2 exit 0 fi - nix --extra-experimental-features 'nix-command flakes' \ + sh "{{ justfile_directory() }}/nix/with-github-auth.sh" \ + nix --extra-experimental-features 'nix-command flakes' \ flake update --flake "{{ justfile_directory() }}/nix" # Update all user-scope flatpaks (Flathub apps + URL bundles when their version changes) 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 "$@" |
