Expert guidance for agents to manage local Nix profiles for installing tools and dependencies. Covers flakes, profile management, package searching, and registry configuration.
64
52%
Does it follow best practices?
Impact
74%
1.42xAverage score across 3 eval scenarios
Advisory
Suggest reviewing before use
Optimize this skill with Tessl
npx tessl skill review --optimize ./nix-profile-manager/SKILL.mdThis skill enables agents to maintain a local Nix profile in a user-provided directory, allowing dynamic installation of tools without requiring system-wide package management or sudo access.
Users should provide a directory in their PATH for the agent to manage, and ensure the AGENT_PROFILE env var contains this directory so the agent knows where it is.
Then the agent just does:
nix profile add --profile "$AGENT_PROFILE" "nixpkgs#git"The --profile flag tells Nix to store the profile metadata in that location.
The bin dir created by Nix in the profile must be in the PATH.
NOTE: on older Nix versions, the add sub-command was called install. Keep this in mind if you get errors saying that "add" does not exist.
A profile is a directory containing:
manifest.json - list of installed packages and their flake referencesbin, lib, share, etc. - folders with symlinks to binaries, libs, docs in the Nix storeWhen you run nix profile add, Nix updates the manifest and recreates symlinks.
A flake is a standardized Nix package collection with:
flake.nix file defining inputs and outputsflake.lockCommon flakes:
nixpkgs - Standard package library (the default registry), usually an alias for github:NixOS/nixpkgs/nixpkgs-unstablegithub:user/repo)git, python311)<flake>#<package>IMPORTANT: In some flakes (like nixpkgs) packages can be nested: <flake>#<scope>.<package>
# Search in nixpkgs flake:
nix search nixpkgs git
# Search in specific (fully qualified) flake
nix search "github:user/repo[/branch]" <package-name>
# Or get a more detailed JSON output
nix search nixpkgs python3 --json | jq '.[].pname'# Add package
nix profile add --profile <profile_path> "<flake>#<package>"
# List installed packages
nix profile list --profile <profile_path>
# Remove by index or element number
nix profile remove --profile <path>/profile 0
# Upgrade packages
nix profile upgrade --profile <profile_path> <package_name>
nix profile upgrade --profile <profile_path> --all # All packages installed in this profile# List available flake aliases
nix registry list
# Add custom registry entry (user-level)
nix registry add myflake github:user/repo/branch# Determine profile path:
echo $AGENT_PROFILE # If not defined, ask the user which profile to use!!
# Search for the package
nix search nixpkgs git
# Add it
nix profile add --profile "$AGENT_PROFILE" "nixpkgs#git"
# Just use it!
tool-cmd ...bin sub-folder should be in PATH: The directory containing the profile must be in $PATH for linked binaries to be accessiblenixpkgs#git resolves to the current nixpkgs version; use github:user/repo/ref#package to pin to specific refsPackage not found:
nix registry list shows available aliasesnix search <flake> <partial-name> to find exact package nameCommand not in PATH after install:
$PATH: echo $PATHls -la $AGENT_PROFILE (adjust path as needed)Permission denied:
references/flakes.md - In-depth flake concepts and GitHub referencesreferences/package-search.md - Advanced package discovery techniquesreferences/profile-internals.md - Profile structure and manifest formatreferences/registry.md - Custom registry configuration and pinningWhen implementing profile management in an agent:
AGENT_PROFILE or function arg--json output for parsing - more reliable than text outputaed1afb
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.