Skip to content
Back to skills

Nix Best Practices

ASecurity

Use when writing or changing Nix flakes, overlays, shell.nix, or flake.nix files, or resolving their evaluation errors.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 16, 2026
ai-agentsgoshell

Works with

  • cli

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add alleneubank/agent-profile --skill nix-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nix Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nix Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alleneubank-nix-best-practices/badge)](https://www.skillsdirectory.com/skills/alleneubank-nix-best-practices)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nix-best-practices
description: Use when writing or changing Nix flakes, overlays, shell.nix, or flake.nix files, or resolving their evaluation errors.
---

# Nix Best Practices

## Follows

Point each input's `nixpkgs` at the root one so the lock holds a single
nixpkgs:

```nix
some-overlay.inputs.nixpkgs.follows = "nixpkgs";
# another input's input is a path, not an input name
another-overlay.inputs.nixpkgs.follows = "some-overlay/nixpkgs";
```

`follows = "some-overlay"` substitutes the `some-overlay` flake itself for
nixpkgs. `nix flake metadata` prints what each input resolved to.

## Unfree packages

`nixpkgs.legacyPackages.${system}` refuses unfree packages, and a flake
evaluates purely, so `NIXPKGS_ALLOW_UNFREE=1` is read only with `--impure`
(`.envrc`: `use flake --impure`). To allow them without user setup, import
nixpkgs in the flake:

```nix
pkgs = import nixpkgs {
  inherit system;
  config.allowUnfreePredicate = pkg:
    builtins.elem (nixpkgs.lib.getName pkg) [ "specific-package" ];
};
```

## Overlays and hashes

- Define `overlays.default` once at the flake's top level, outside any
  per-system helper, and read the system inside it as
  `prev.stdenv.hostPlatform.system`; `prev.system` warns as renamed.
- `nix-prefetch-url <url>` prints a base32 hash. Convert it with
  `nix hash convert --hash-algo sha256 --to sri <hash>`; `nix hash to-sri` is
  deprecated.

## Current facts

Answer flag questions from the installed CLI first: `nix --version` and
`nix <command> --help`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.