A Nix flake that packages the GitHub Copilot CLI for easy installation on NixOS and with Home Manager.
This repository provides a Nix flake that packages the GitHub Copilot CLI, allowing you to easily install and use GitHub Copilot in your terminal on NixOS systems or through Home Manager. This flake is updated weekly with the last version of Copilot.
It also packages Headroom, the token compressor for LLM applications, as a separate headroom output.
- Nix with flakes enabled
- A GitHub account with Copilot access
- For Home Manager usage: Home Manager installed and configured
The easiest way to try the GitHub Copilot CLI is using the development shell:
# Clone this repository
git clone <repository-url>
# Enter the development shell
nix develop
# The copilot command should now be available
copilot --help
# 'copilot-hr' is also available: it's 'copilot' transparently wrapped
# through the Headroom proxy for token compression.
copilot-hr --helpTo build the package locally:
nix buildThe built package will be available in the result symlink.
This flake also builds Headroom as its own package output, using the official prebuilt headroom-ai PyPI wheel plus nixpkgs' ast-grep for the binary it shells out to (no plain pass-through of a nixpkgs package):
nix build .#headroom
./result/bin/headroom --helpIt's also included in the default development shell alongside copilot. The proxy extra (needed for headroom proxy / headroom wrap <tool>) is packaged too; only ML-only extras (e.g. the Kompress-v2-base prose model, some agent-specific wrappers) are left out and fail with a clear ImportError if invoked.
This flake exposes ready-to-use modules, for NixOS, Home Manager and devenv, built around a programs.copilotCli option namespace (copilotCli for devenv):
# NixOS / Home Manager
{
imports = [ copilot-cli.nixosModules.default ]; # or homeManagerModules.default
programs.copilotCli.enable = true;
}# devenv.nix
{ inputs, ... }: {
imports = [ inputs.copilot-cli.devenvModules.default ];
copilotCli.enable = true;
}enable alone installs the plain copilot command. Enabling the nested headroom option additionally (or instead) installs it wrapped through the Headroom proxy (headroom wrap copilot):
# Only the Headroom-wrapped copilot is installed; running `copilot`
# transparently goes through Headroom.
programs.copilotCli = {
enable = true;
headroom.enable = true;
};# Both are installed side by side: plain `copilot`, and `copilot-hr` wrapped
# with Headroom.
programs.copilotCli = {
enable = true;
headroom = {
enable = true;
wrapperName = "copilot-hr";
};
};Options:
| Option | Default | Description |
|---|---|---|
enable |
false |
Install the GitHub Copilot CLI. |
package |
this flake's default package |
The GitHub Copilot CLI package to install. |
headroom.enable |
false |
Additionally install copilot wrapped with Headroom. |
headroom.package |
this flake's headroom package |
The Headroom package used to run the proxy. |
headroom.wrapperName |
"copilot" |
Command name for the wrapper. When "copilot" (the default), it replaces the plain copilot command (only the wrapped binary is installed). Set to e.g. "copilot-hr" to install it alongside the plain copilot command instead. |
headroom.port |
8787 |
Local port used by the Headroom proxy. |
headroom.subscription |
false |
Pass --subscription (route via your GitHub Copilot subscription instead of a BYOK provider key). |
headroom.extraWrapArgs |
[ ] |
Extra arguments forwarded to headroom wrap copilot (e.g. [ "--backend" "anyllm" ]). |
The wrapper always resolves the real copilot binary first (it prepends the plain package's bin directory to PATH), so it's safe even when wrapperName is "copilot" itself — it cannot recurse into itself.
All methods below need this flake added as an input first:
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
copilot-cli.url = "github:scarisey/copilot-cli-flake";
# If also using Home Manager:
home-manager.url = "github:nix-community/home-manager";
};
# ...
}Use the programs.copilotCli module described in Copilot CLI module, with optional Headroom wrapping above — it handles installation and, optionally, Headroom wrapping for you:
{
imports = [ copilot-cli.nixosModules.default ]; # or homeManagerModules.default
programs.copilotCli.enable = true;
}This works the same way whether Home Manager is used standalone, as a NixOS module (home-manager.users.<user> = { imports = [ copilot-cli.homeManagerModules.default ]; programs.copilotCli.enable = true; }), or for devenv (copilotCli.enable = true with devenvModules.default).
If you don't need the module (e.g. no Headroom wrapping, or you manage packages manually), reference the package output directly:
# NixOS: environment.systemPackages
# Home Manager: home.packages
[ copilot-cli.packages.${pkgs.system}.default ]For a quick, non-declarative installation:
nix profile install github:scarisey/copilot-cli-flake # from the flake
nix profile install . # from a local cloneThis flake supports the following systems:
x86_64-linuxaarch64-linuxx86_64-darwinaarch64-darwin
After installation, you'll need to authenticate with GitHub:
# Start the authentication process with Github CLI
gh auth login
# Follow the prompts to authenticate with your GitHub accountOnce installed and authenticated, you can use GitHub Copilot CLI:
# Get help
copilot --help
# Just start interactive mode
copilot
# Execute a prompt in non-interactive mode
copilot -p "Fix the bug in main.js" --allow-all-tools
To update to a newer version of the GitHub Copilot CLI:
Use update.sh script that will do the following :
- Update the
versioninpackage.nix - Update the
urlandsha256in thefetchurlcall - Update the
npmDepsHash
# Enter the development shell
nix develop
# Make changes to package.nix or flake.nix
# Test your changes
nix build
# Test the development shell
nix develop --command copilot --helpIf you get an error about flakes not being enabled, add this to your Nix configuration:
# /etc/nixos/configuration.nix
nix.settings.experimental-features = [ "nix-command" "flakes" ];Or for non-NixOS systems, add to ~/.config/nix/nix.conf:
experimental-features = nix-command flakes
If you have trouble with authentication:
- Make sure you have a GitHub account with Copilot access
- Try logging out and back in:
copilot auth logoutthencopilot auth login - Check your internet connection and GitHub's status
If the copilot command is not found after installation:
- Make sure the package is in your PATH
- Try restarting your shell or sourcing your profile
- For Home Manager users, ensure you've run
home-manager switch
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit issues or pull requests.
For more information about GitHub Copilot CLI, visit the official documentation.