Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aeshakhzod avatar

Nix

  • 1 installs
  • Updated January 23, 2026
  • aeshakhzod/nixos-and-flakes-skill

nix is a Claude Code skill for NixOS, Nix Flakes, Home Manager, and nix-darwin, covering declarative system configuration and reproducible cross-platform environments.

About

nix is a Claude Code skill for NixOS, Nix Flakes, Home Manager, and nix-darwin. It covers declarative system configuration, reproducible environments pinned by flake.lock, the module system, package overrides and overlays, and cross-platform (Linux/macOS) workflows. Developers use it to build and maintain reproducible machines and dev shells and to recover via NixOS generation rollback.

  • Covers NixOS, Nix Flakes, Home Manager, and nix-darwin declarative configuration
  • Reproducible environments via flake.lock plus rollback through NixOS generations
  • Command reference for rebuild, dev shells, updates, and GC, with common gotchas

Nix by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #1,173 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
At a glance

nix capabilities & compatibility

Free open-source toolchain.

Capabilities
declarative config · reproducible environments · package management
Works with
github
Use cases
devops
Platforms
Linux · macOS
Pricing
Free
From the docs

What nix says it does

Covers declarative system configuration, reproducible environments, package management, and cross-platform Nix workflows.
SKILL.md
**Untracked files ignored** - `git add` before any flake command
SKILL.md
npx skills add https://github.com/aeshakhzod/nixos-and-flakes-skill --skill nix

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
Last updatedJanuary 23, 2026
Repositoryaeshakhzod/nixos-and-flakes-skill

What it does

Write and maintain declarative, reproducible NixOS, Home Manager, or nix-darwin configurations and dev shells across Linux and macOS.

Who is it for?

Declarative, reproducible NixOS/Home Manager/nix-darwin configs and dev shells.

Skip if: Imperative, step-by-step system setup rather than declared desired state.

When should I use this skill?

You are doing any Nix, NixOS, Flakes, Home Manager, or nix-darwin task.

By the numbers

  • 7 common gotchas listed
  • 9 reference files (flakes, home-manager, nix-darwin, nix-language, etc.)

Files

SKILL.mdMarkdownGitHub ↗

Nix Ecosystem Guide

Core Philosophy

1. Declarative over Imperative - Describe desired state, not steps to reach it 2. Reproducibility - Lock files (flake.lock) pin exact versions 3. Immutability - Nix Store is read-only; same inputs = same outputs 4. Rollback (NixOS) - Every generation preserved; instant recovery via boot menu

Flake Structure

{
  description = "My Nix configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      inputs.nixpkgs.follows = "nixpkgs";  # CRITICAL: avoid duplicate nixpkgs
    };
    # macOS support
    nix-darwin = {
      url = "github:nix-darwin/nix-darwin/nix-darwin-24.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, home-manager, nix-darwin, ... }@inputs: {
    # NixOS configurations
    nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ ./configuration.nix ];
    };

    # macOS configurations
    darwinConfigurations.hostname = nix-darwin.lib.darwinSystem {
      system = "aarch64-darwin";  # or x86_64-darwin for Intel
      modules = [ ./darwin.nix ];
    };

    # Development shells
    devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
      packages = [ /* ... */ ];
    };
  };
}

Essential Patterns

Input Management

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

  # Use parent's nixpkgs to avoid downloading multiple versions
  home-manager.inputs.nixpkgs.follows = "nixpkgs";

  # Non-flake input (config files, etc.)
  private-config = {
    url = "git+ssh://git@github.com/user/config.git";
    flake = false;
  };
};

Module System

# Modules have: imports, options, config
{ config, pkgs, lib, ... }: {
  imports = [ ./hardware.nix ./services.nix ];

  options.myOption = lib.mkOption {
    type = lib.types.bool;
    default = false;
  };

  config = lib.mkIf config.myOption {
    # conditional configuration
  };
}

Priority Control

{
  # lib.mkDefault (priority 1000) - base module defaults
  services.nginx.enable = lib.mkDefault true;

  # Direct assignment (priority 100) - normal config
  services.nginx.enable = true;

  # lib.mkForce (priority 50) - override everything
  services.nginx.enable = lib.mkForce false;
}

Package Customization

{
  # Override function arguments
  pkgs.fcitx5-rime.override { rimeDataPkgs = [ ./custom-rime ]; }

  # Override derivation attributes
  pkgs.hello.overrideAttrs (old: { doCheck = false; })

  # Overlays (global modification)
  nixpkgs.overlays = [
    (final: prev: {
      myPackage = prev.myPackage.override { /* ... */ };
    })
  ];
}

Platform-Specific

NixOS

sudo nixos-rebuild switch --flake .#hostname
sudo nixos-rebuild boot --flake .#hostname    # apply on next boot
sudo nixos-rebuild test --flake .#hostname    # test without boot entry

nix-darwin (macOS)

darwin-rebuild switch --flake .#hostname
# TouchID for sudo:
# security.pam.services.sudo_local.touchIdAuth = true;

Home Manager

# As NixOS/Darwin module:
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.username = import ./home.nix;

# Standalone:
home-manager switch --flake .#username@hostname

Commands Reference

TaskCommand
Rebuild NixOSsudo nixos-rebuild switch --flake .#hostname
Rebuild Darwindarwin-rebuild switch --flake .#hostname
Dev shellnix develop
Temp packagenix shell nixpkgs#package
Run packagenix run nixpkgs#package
Update allnix flake update
Update onenix flake update nixpkgs
GC old genssudo nix-collect-garbage -d
List gensnix profile history --profile /nix/var/nix/profiles/system
Debug buildnixos-rebuild switch --show-trace -L -v
REPLnix repl then :lf . to load flake

Common Gotchas

1. Untracked files ignored - git add before any flake command (nix build/run/shell/develop, nixos-rebuild, darwin-rebuild) 2. allowUnfree fails in devShells - Use nixpkgs-unfree overlay or ~/.config/nixpkgs/config.nix 3. Duplicate input downloads - Use follows to pin dependencies (most common: inputs.nixpkgs.follows) 4. Python pip fails - Use venv, poetry2nix, or containers 5. Downloaded binaries fail - Use FHS environment or nix-ld 6. Merge conflicts in lists - Use lib.mkBefore/lib.mkAfter for ordering 7. Build from source unexpectedly - Check if overlays invalidate cache

Development Environments

# In flake.nix outputs:
devShells.x86_64-linux.default = pkgs.mkShell {
  packages = with pkgs; [ nodejs python3 rustc ];

  shellHook = ''
    echo "Dev environment ready"
    export MY_VAR="value"
  '';

  # For C libraries
  LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.openssl ];
};

direnv Integration

# .envrc
use flake
# or for unfree: use flake --impure

Debugging

# Verbose rebuild
nixos-rebuild switch --show-trace --print-build-logs --verbose

# Interactive REPL
nix repl
:lf .                    # load current flake
:e pkgs.hello           # open in editor
:b pkgs.hello           # build derivation
inputs.<TAB>            # explore inputs

References

For detailed information, see:

  • references/nix-language.md - Nix language syntax
  • references/flakes.md - Flake inputs/outputs details
  • references/home-manager.md - User environment management
  • references/nix-darwin.md - macOS configuration
  • references/nixpkgs-advanced.md - Overlays, overrides, callPackage
  • references/dev-environments.md - Dev shells, direnv, FHS
  • references/best-practices.md - Modularization, debugging, deployment
  • references/templates.md - Ready-to-use flake.nix examples

Related skills

FAQ

How do I avoid duplicate nixpkgs downloads?

Use inputs.nixpkgs.follows to pin dependencies to the parent's nixpkgs.

Why does a flake command ignore my new file?

Untracked files are ignored; git add before running any flake command.

DevOps & CI/CDinfradeploy

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.