This document describes a **declarative installation of the GitHub Copilot CLI** on NixOS (25.11).
This method creates a small local Nix package that:
- installs the Copilot CLI via npm
- works with NixOS’s dynamic linking model using nix-ld
- integrates with the system configuration
- A machine running **NixOS 25.11**
- A **GitHub Copilot subscription** (required for login)
- Familiarity with editing /etc/nixos/configuration.nix
You will create:
| Path | Description |
|---|---|
| etc/nixos/pkgs | local package definitions |
| copilot-cli.nix | wrapper package for Copilot CLI |
sudo mkdir -p /etc/nixos/pkgs
sudo nano /etc/nixos/pkgs/copilot-cli.nixPaste this content into copilot-cli.nix:
{ pkgs }:
pkgs.writeShellScriptBin "copilot" ''
#!/usr/bin/env bash
set -euo pipefail
# Local installation directory
export PREFIX="$HOME/.local/share/copilot-cli"
export NPM_CONFIG_PREFIX="$PREFIX"
# Ensure Node from Nixpkgs
export PATH="${pkgs.nodejs_22}/bin:$PREFIX/bin:$PATH"
if ! command -v copilot >/dev/null; then
echo "Installing GitHub Copilot CLI..."
mkdir -p "$PREFIX"
npm install -g @github/copilot@latest
fi
exec "$PREFIX/bin/copilot" "$@"
''Open your system config:
sudo nano /etc/nixos/configuration.nixAdd this inside the top‑level config block:
{ config, pkgs, ... }:
let
copilot-cli = pkgs.callPackage ./pkgs/copilot-cli.nix {};
in {
;; Enable nix-ld for dynamic binaries
programs.nix-ld.enable = true;
;; Install the Copilot package
environment.systemPackages = [
copilot-cli
];
;; (Optional) Add extra libs if needed
;; programs.nix-ld.libraries = with pkgs; [ openssl zlib ];
}Run the rebuild:
sudo nixos-rebuild switchThis step:
- Enables nix-ld (to support Copilot’s prebuilt native executable)
- Adds the `copilot` wrapper to your system path
Run Copilot:
copilot --helpOn first run it will:
- install the real Copilot CLI into ~/.local/share/copilot-cli
- then launch with –help output
To login:
copilot auth loginFollow the interactive GitHub authentication flow.
To update to the latest Copilot CLI:
rm -rf ~/.local/share/copilot-cli
copilot --helpThis re‑installs the latest version.
If you want both `copilot` and `copilot-cli`:
let
copilot = pkgs.callPackage ./pkgs/copilot-cli.nix {};
copilot-cli = pkgs.writeShellScriptBin "copilot-cli" ''
exec ${copilot}/bin/copilot "$@"
'';
in {
environment.systemPackages = [ copilot copilot-cli ];
}Org Mode is plain‑text markup for outlining and documenting. Headings start with `*`, lists are defined with `-` or `+`, and code blocks use `#+BEGIN_SRC … #+END_SRC`. :contentReference[oaicite:1]{index=1}
NixOS normally lacks a traditional dynamic loader path (e.g., `/lib64/ld-linux-x86-64.so.2`). Tools like Copilot CLI ship native binaries expecting that path, so we enable nix-ld to allow them to run on NixOS. The nix-ld integration is explicitly supported for just this purpose.
This process gives you:
- a **declarative NixOS configuration** for Copilot CLI
- the ability to run the upstream CLI without polluting global npm installs
- an easily maintainable, Nix‑friendly workflow
Happy coding!