This Flox environment permits (more) secure GitHub CLI auth by storing GitHub tokens and Git credentials locally using standard methods. It gives you two storage options:
- System keyring/keychain (preferred) - Uses OS security infrastructure;
- Encrypted local file (fallback) - Encrypts your credentials with a system-derived key.
- Stores GitHub tokens and Git credentials in your system keyring or in encrypted files;
- Handles GitHub CLI & Git auth automatically without manually entering credentials;
- Works across platforms (macOS, Linux, Windows/WSL2);
- Hooks into Bash, Zsh, and Fish shells;
- Includes a clean, elegant setup wizard that walks you through the config;
- Also configures Git user identity information if needed.
The environment packs these essential tools:
gh- GitHub CLI for interacting with GitHub repositoriesgit- Version control systemgum- Terminal UI toolkit powering the setup wizardbat- Bettercatwith syntax highlightingcurl- Solid HTTP client for API testingopenssl- Cryptography toolkit backing the security layercoreutils- Includes required GNU tools # included for macOS compatibilitygnused- GNUsededitor # included for macOS compatibilitygawk- GNU implementation ofawk# included for macOS compatibilitygnugrep- GNU implementation ofgrep# included for macOS compatibility
- GitHub account
- GitHub Personal Access Token with appropriate permissions
- Flox installed on your system
Jump in with:
- Clone this repo
git clone https://github.com/yourusername/ghcli && cd ghcli- Run:
flox activateThis command:
- Pulls in all dependencies;
- Fires up the auth setup wizard;
- Drops you into the Flox env with GitHub CLI ready to go.
First-time activation triggers a wizard that:
- Walks you through GitHub token creation if needed;
- Locks your token in the system keyring or encrypted file;
- Sets up shell wrapper functions for transparent auth;
- Configures Git credentials for GitHub;
- Sets up Git
user.nameanduser.emailif not already configured;
After setup, you can directly run GitHub CLI commands:
# List repositories
gh repo list
# Create a pull request
gh pr create
# View issues
gh issue listYou can also use Git commands without credential prompts:
# Clone a repository
git clone https://github.com/username/repo.git
# Push changes
git push
# Pull updates
git pullAuth happens automatically via your configured mechanism.
We implement a two-tiered storage strategy:
-
Primary Storage: System keyring/keychain
- Uses OS security mechanisms
- Gets the same protection as your system credentials
-
Fallback Storage: Encrypted file
- Implements AES-256-CBC encryption
- Derives keys from unique system attributes:
- Username
- Hostname
- Machine ID
- Creates deterministic but unique keys for each system
The environment builds shell-specific wrappers that:
- Pull your credentials from secure storage;
- Inject them as environment variables for GitHub CLI;
- Configure Git to use appropriate credential helpers.
The environment configures Git's credential system to:
- Use macOS Keychain on macOS systems;
- Use the system keyring (secret-tool) on Linux when available;
- Fall back to encrypted files when system keyring is unavailable;
- Set up
gituser.nameanduser.emailfor commit attribution.
If GitHub auth breaks:
-
Auth fails in environment:
- Exit the environment;
- Run
flox activateagain; if config is corrupted, this should re-trigger setup
-
Persistent failures:
- Exit the environment;
- Nuke the
~/.cache/flox/ghcli/folder; - Either:
- Clone the repo again; or
- Create (
mkdir) a new repo folder and runflox pull --copy yourusername/ghcli;
- Enter clean environment with
flox activate.
-
Keyring issues:
- If no system keyring is available / detected, the wizard falls back to encrypted file storage.
This works on:
- macOS (ARM64, x86_64)
- Linux (ARM64, x86_64)
- Tokens and credentials never exist as plaintext files;
- System keyring implements OS-native security;
- Encrypted files use system-derived keys that can't be easily guessed;
- Network traffic only occurs during GitHub API validation;
- All sensitive files receive restricted permissions (600).
Linux Keyring Note: On Linux, with both GNOME Keyring and KWallet it is possible to dump credentials if an attacker gains access to your active, unlocked session. While sufficient for most use cases, they don't match the security of dedicated password managers.
For hardened environments:
- Consider dedicated password managers for credential storage;
- Lock your system when you step away? (d'uh and/or d'uh?)
Flox builds on Nix to provide:
- Declarative environments - Software, variables, services defined in TOML
- Content-addressed storage - Multiple package versions coexist without conflicts
- Reproducibility - Same environment across dev, CI, and production
- Deterministic builds - Same inputs always produce identical outputs
- Huge package collection - Access to 150,000+ packages from Nixpkgs
MIT