From 52b55691c1c4a3af302b8ee30d6b24aa5c33fd3c Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 17 Sep 2024 22:28:33 +0300 Subject: [PATCH] doc/by-name: explain better `callPackage` and `xWithY=x.override` transition --- pkgs/by-name/README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/README.md b/pkgs/by-name/README.md index b337c8c78301..5eb121b4f3f0 100644 --- a/pkgs/by-name/README.md +++ b/pkgs/by-name/README.md @@ -90,11 +90,29 @@ if package maintainers would like to use this feature, they are welcome to migra To lessen PR traffic, they're encouraged to also perform some more general maintenance on the package in the same PR, though this is not required and must not be expected. -Note that definitions in `all-packages.nix` with custom arguments should not be removed. +Note that `callPackage` definitions in `all-packages.nix` with custom arguments should not be removed. That is a backwards-incompatible change because it changes the `.override` interface. Such packages may still be moved to `pkgs/by-name` however, in order to avoid the slightly superficial choice of directory / category in which the `default.nix` file was placed, but please keep the definition in `all-packages.nix` using `callPackage`. See also [changing implicit attribute defaults](#changing-implicit-attribute-defaults). +Definitions like the following however, _can_ be transitioned: + +```nix +# all-packages.nix +fooWithBaz = foo.override { + bar = baz; +}; +# turned into pkgs/by-name/fo/fooWithBaz/package.nix with: +{ + foo, + baz, +}: + +foo.override { + bar = baz; +} +``` + ## Limitations There's some limitations as to which packages can be defined using this structure: