Nix

From nix-community/nur-combined · View interactive version

Nix is an AI agent skill from the GitHub repository nix-community/nur-combined. Run packages temporarily, create isolated shell environments, and evaluate Nix expressions. Use when executing tools without installing, debugging derivations, or searching nixpkgs.

How to use this skill

Skill file

Nix Skill

Nix is a powerful package manager and functional programming language. This skill covers common operations like running apps on-the-fly and managing environments.

Running Applications

You can run any application from nixpkgs without installing it permanently.

# Run a package once
nix run nixpkgs#hello

# Run a package with specific arguments
nix run nixpkgs#cowsay -- "Hello from Nix!"

# Run a command within a shell environment (non-interactive)
nix shell nixpkgs#git nixpkgs#vim --command git --version

# Run long-running applications (e.g., servers): `tmux new -d 'nix run nixpkgs#some-server'`

Formatting

Format Nix files in your project:

# Format current flake
nix fmt

# Check formatting
nix fmt -- --check

Evaluating Expressions (Debugging)

Since the environment is headless and non-interactive, use nix eval instead of the REPL for debugging.

# Evaluate a simple expression
nix eval --expr '1 + 2'

# Inspect an attribute from nixpkgs
nix eval nixpkgs#hello.name

# Evaluate a local nix file
nix eval --file ./default.nix

# List keys in a set (useful for exploration)
nix eval --expr 'builtins.attrNames (import <nixpkgs> {})'

Searching for Packages

# Search for a package by name or description
nix search nixpkgs python3

Common Nix Language Patterns

Variables and Functions

# Let binding
let
  name = "Nix";
in
  "Hello ${name}"

# Function definition
let
  multiply = x: y: x * y;
in
  multiply 2 3

Attribute Sets

{
  a = 1;
  b = "foo";
}

Shebang Scripts

Use Nix as a script interpreter:

#!/usr/bin/env nix
#! nix shell nixpkgs#bash nixpkgs#curl --command bash

curl -s https://example.com

Or with flakes:

#!/usr/bin/env nix
#! nix shell nixpkgs#python3 --command python3

print("Hello from Nix!")

Troubleshooting

Related Skills

Related Tools

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.