NixOS / NixOS/nix.dev

Recommend `pkgs.newScope` over `lib.callPackageWith`

Open
#1,183 0 comments 3 reactions 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
lib.callPackageWith doesn't bring pkgs.xorg the way regular pkgs.callPackage does.

https://github.com/NixOS/nixpkgs/blob/42cd7da40a9c88dd0ec2ea4f2682093f54c6c41a/lib/customisation.nix#L259-L324

https://github.com/NixOS/nixpkgs/blob/42cd7da40a9c88dd0ec2ea4f2682093f54c6c41a/pkgs/top-level/splice.nix#L142-L160

Since pkgs.callPackage is just pkgs.newScope { }:

https://github.com/NixOS/nixpkgs/blob/42cd7da40a9c88dd0ec2ea4f2682093f54c6c41a/pkgs/top-level/splice.nix#L170

we should be recommending pkgs.newScope as a less unwieldy method that properly preserves the pkgs.callPackage behavior.

Problem

Approaches

Willing to help?

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 documentation for recommendations involving lib.callPackageWith, then compare the linked lib/customisation.nix and pkgs/top-level/splice.nix sections. Confirm how pkgs.newScope relates to pkgs.callPackage, update the relevant guidance, and verify that the documentation consistently recommends the intended approach.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.