Nix Ecosystem

This skill should be used when the user asks to "write nix", "nix expression", "flake.nix", "home-manager config", "programs.*", "services.*", or works with Nix language, flakes, or Home Manager. Provides comprehensive Nix ecosystem patterns and best practices.

$ Installieren

git clone https://github.com/takeokunn/nixos-configuration /tmp/nixos-configuration && cp -r /tmp/nixos-configuration/home-manager/programs/claude-code/skills/nix-ecosystem ~/.claude/skills/nixos-configuration

// tip: Run this command in your terminal to install the skill


name: Nix Ecosystem description: This skill should be used when the user asks to "write nix", "nix expression", "flake.nix", "home-manager config", "programs.", "services.", or works with Nix language, flakes, or Home Manager. Provides comprehensive Nix ecosystem patterns and best practices.

<nix_language> Nix is lazily evaluated. Expressions are only computed when needed.

Only evaluates needed attributes

let expensive = builtins.trace "Computing expensive" (1 + 1); in { a = 1; b = expensive; }.a # Does not compute expensive

Avoid side effects; use derivations for build actions

buildResult = pkgs.stdenv.mkDerivation { ... };

Access patterns

set.attr set."attr-with-dashes"

Recursive attribute set

rec { a = 1; b = a + 1; }

nativeBuildInputs = [ pkgs.cmake ]; buildInputs = [ pkgs.openssl ];

installPhase = '' mkdir -p $out/bin cp mypackage $out/bin/ ''; } Required attributes: pname, version, src Standard phases: unpackPhase, patchPhase, configurePhase, buildPhase, installPhase

Libraries linked at runtime

buildInputs = [ openssl zlib ]; }

config = lib.mkIf config.myModule.enable { # configuration when enabled }; }

<anti_patterns> Directly referencing absolute paths breaks reproducibility Use fetchurl, fetchFromGitHub, or relative paths within the repository

inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; };

outputs = { self, nixpkgs, ... }@inputs: { # output attributes }; }

<home_manager> Standard Home Manager module structure { config, pkgs, lib, ... }: { options.custom.feature = { enable = lib.mkEnableOption "feature description"; };

config = lib.mkIf config.custom.feature.enable { # configuration when enabled }; }

<common_modules> Git version control configuration programs.git = { enable = true; userName = "Your Name"; userEmail = "email@example.com"; signing = { key = "KEY_ID"; signByDefault = true; }; aliases = { co = "checkout"; st = "status"; }; extraConfig = { core.editor = "nvim"; }; };

<best_practices> Use programs.* when available instead of manual configuration

<error_escalation> Style inconsistency in Nix expression Note issue, suggest formatting Evaluation error or type mismatch Debug with --show-trace, fix expression Build failure in derivation Analyze build log, present options to user Impure expression breaking reproducibility Block operation, require pure alternatives </error_escalation>

<related_agents> Architecture and module dependency analysis for Nix configurations Implementation of flake outputs, Home Manager modules, and NixOS configurations Nix expression validation, formatting, and best practices enforcement </related_agents>

<related_skills> Symbol operations for navigating Nix expressions and module definitions Fetch latest nixpkgs and Home Manager documentation Debug evaluation errors and understand derivation failures </related_skills>

home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.username = import ./home.nix; }

Repository

takeokunn
takeokunn
Author
takeokunn/nixos-configuration/home-manager/programs/claude-code/skills/nix-ecosystem
52
Stars
0
Forks
Updated5d ago
Added1w ago