NixOS / NixOS/nix.dev

Teach pure interfaces by default

Open
#1,049 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

site
Dominant language
Nix
Stars
4k
Forks
339
Avg merge
2d 11h
Merged PRs (30d)
7

Description

Observations

We're currently showing patterns like

pkgs = import nixpkgs { config = {}; overlays = []; system = builtins.currentSystem; };

as a defensive measure against historical, impure interfaces that may mess with your expression if you happened to follow the ancient documentation on configuring Nixpkgs.

Problem

Dismantling the Nixpkgs manual is a big chunk of work, and in any case that wouldn't remove the convenient-looking but foot-gunny impure interface which is used absolutely everywhere.

Approaches

Until https://github.com/NixOS/nixpkgs/issues/339635 is settled, we can only show the ugly but technically correct

pkgs = import "${nixpkgs}/pkgs/top-level" { localSystem.system = builtins.currentSystem; };

and may eventually please today's new users with a future release that makes the interface less verbose.
This would require replacing all instances where we use it, and updating the relevant best practices section.

Willing to help?

As always.

Priorities

Add 👍 to issues you find important.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the nix.dev repository for instances of the impure Nixpkgs import pattern shown in the issue, then locate the relevant best-practices section. Replace the documented examples with the technically correct interface described here and update that guidance; done means the old pattern is no longer presented in the affected documentation.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.