Skip to content

A Nix flake that packages the GitHub Copilot CLI for easy installation on NixOS and with Home Manager.

License

Notifications You must be signed in to change notification settings

scarisey/copilot-cli-flake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Copilot CLI - Nix Package

A Nix flake that packages the GitHub Copilot CLI for easy installation on NixOS and with Home Manager.

Overview

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.

Prerequisites

  • Nix with flakes enabled
  • A GitHub account with Copilot access
  • For Home Manager usage: Home Manager installed and configured

Quick Start

Using the Development Shell

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

Building the Package

To build the package locally:

nix build

The built package will be available in the result symlink.

Installation Methods

Method 1: NixOS System Configuration

Add this flake to your NixOS system configuration:

# /etc/nixos/configuration.nix or flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    copilot-cli.url = "github:scarisey/copilot-cli-flake";
  };

  outputs = { self, nixpkgs, copilot-cli, ... }: {
    nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux"; # or your system architecture
      modules = [
        {
          environment.systemPackages = [
            copilot-cli.packages.x86_64-linux.default # Adjust architecture as needed
          ];
        }
        # ... your other modules
      ];
    };
  };
}

Then rebuild your system:

sudo nixos-rebuild switch

Method 2: Home Manager (Standalone)

If you're using Home Manager as a standalone tool:

# ~/.config/home-manager/home.nix
{ config, pkgs, ... }:

let
  copilot-cli = builtins.getFlake "github:scarisey/copilot-cli-flake";
in
{
  home.packages = [
    copilot-cli.packages.${pkgs.system}.default
  ];

  # Rest of your Home Manager configuration...
}

Apply the configuration:

home-manager switch

Method 3: Home Manager (NixOS Module)

If you're using Home Manager as a NixOS module:

# /etc/nixos/configuration.nix or your flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    copilot-cli.url = "github:scarisey/copilot-cli-flake";
  };

  outputs = { self, nixpkgs, home-manager, copilot-cli, ... }: {
    nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        home-manager.nixosModules.home-manager
        {
          home-manager.users.yourusername = {
            home.packages = [
              copilot-cli.packages.x86_64-linux.default
            ];
          };
        }
        # ... your other modules
      ];
    };
  };
}

Method 4: Direct Installation with Nix Profile

For a quick one-time installation:

# Install directly from the flake
nix profile install github:scarisey/copilot-cli-flake

# Or install from a local clone
nix profile install .

Supported Architectures

This flake supports the following systems:

  • x86_64-linux
  • aarch64-linux
  • x86_64-darwin
  • aarch64-darwin

Authentication and Setup

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 account

Usage

Once 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

Development

Updating the Package

To update to a newer version of the GitHub Copilot CLI:

Use update.sh script that will do the following :

  1. Update the version in package.nix
  2. Update the url and sha256 in the fetchurl call
  3. Update the npmDepsHash

Local Development

# 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 --help

Troubleshooting

Flakes Not Enabled

If 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

Authentication Issues

If you have trouble with authentication:

  1. Make sure you have a GitHub account with Copilot access
  2. Try logging out and back in: copilot auth logout then copilot auth login
  3. Check your internet connection and GitHub's status

Package Not Found

If the copilot command is not found after installation:

  1. Make sure the package is in your PATH
  2. Try restarting your shell or sourcing your profile
  3. For Home Manager users, ensure you've run home-manager switch

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.


For more information about GitHub Copilot CLI, visit the official documentation.

About

A Nix flake that packages the GitHub Copilot CLI for easy installation on NixOS and with Home Manager.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •