8000 GitHub - numtide/nix-auth: Nix access-token management tool
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

numtide/nix-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nix-auth

Tired of hitting rate limits when running nix flake update? Trying to fetch a private repository in your flake inputs or builtin fetchers?

Nix supports setting access-tokens in your Nix config. This tool makes it easy to get those tokens in the right place.

Features

  • OAuth device flow authentication (no manual token creation needed)
  • Support for multiple providers (GitHub, GitHub Enterprise, and GitLab)
  • Token storage in ~/.config/nix/nix.conf
  • Token validation and status checking
  • Automatic backup creation before modifying configuration

Installation

Using Nix Flakes

Run directly without installation:

nix run github:numtide/nix-auth -- login

Install into your profile:

nix profile install github:numtide/nix-auth

Or add to your system configuration:

{
  inputs.nix-auth.url = "github:numtide/nix-auth";

  # In your system packages
  environment.systemPackages = [
    inputs.nix-auth.packages.${system}.default
  ];
}

Using Go

go install github.com/numtide/nix-auth@latest

From Source

git clone https://github.com/numtide/nix-auth
cd nix-auth
go build .

Usage

Login

Authenticate with GitHub (default provider):

nix-auth login

Authenticate with GitLab:

nix-auth login gitlab

Authenticate with GitHub Enterprise or GitLab self-hosted:

# GitHub Enterprise
nix-auth login github --host github.company.com --client-id <your-client-id>

# GitLab self-hosted
nix-auth login gitlab --host gitlab.company.com --client-id <your-application-id>

The tool will:

  1. Display a one-time code
  2. Open your browser to the provider's device authorization page
  3. Wait for you to authorize the application
  4. Save the token to ~/.config/nix/nix.conf

Note for self-hosted instances:

  • GitHub Enterprise: You'll need to create an OAuth App and provide the client ID via --client-id
  • GitLab self-hosted: You'll need to create an OAuth application and provide the client ID via --client-id

The tool will guide you through this process if the client ID is not provided. You can also set the GITHUB_CLIENT_ID or GITLAB_CLIENT_ID environment variables as an alternative to the --client-id flag.

Check Status

View all configured tokens:

nix-auth status

Logout

Remove a token interactively:

nix-auth logout

Remove a specific provider's token:

nix-auth logout github

Remove a token for a specific host:

nix-auth logout --host github.company.com

How It Works

The tool manages the access-tokens configuration in your ~/.config/nix/nix.conf file. This allows Nix to authenticate when fetching flake inputs from private repositories or builtins fetchers, and hitting rate limits.

Example configuration added by this tool:

access-tokens = github.com=ghp_xxxxxxxxxxxxxxxxxxxx gitlab.com=glpat-xxxxxxxxxxxx github.company.com=ghp_yyyyyyyy

Security

  • Tokens are stored locally in your Nix configuration
  • The tool creates automatic backups before modifying your configuration
  • Uses OAuth device flow for secure authentication
  • Minimal required permissions (only necessary scopes for accessing repositories)

Future Plans

  • Support for more providers (Gitea, Forgejo, Bitbucket, etc.)
  • Token expiration notifications
  • Integration with system keychains for secure storage (will require patching Nix)

License

MIT

About

Nix access-token management tool

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0