From 103a4a5779c95873ca174ad3a56924bf3c1c3dfd Mon Sep 17 00:00:00 2001 From: Will Bush Date: Wed, 3 Apr 2024 20:37:43 -0500 Subject: [PATCH 1/3] tests: move all-packages.nix to pkgs/top-level --- tests/aliases/{ => pkgs/top-level}/all-packages.nix | 0 tests/alt-callPackage/{ => pkgs/top-level}/all-packages.nix | 0 tests/callPackage-syntax/{ => pkgs/top-level}/all-packages.nix | 0 tests/internalCallPackage/{ => pkgs/top-level}/all-packages.nix | 0 .../manual-definition/base/{ => pkgs/top-level}/all-packages.nix | 0 tests/manual-definition/{ => pkgs/top-level}/all-packages.nix | 0 tests/move-to-non-by-name/{ => pkgs/top-level}/all-packages.nix | 0 .../base/{ => pkgs/top-level}/all-packages.nix | 0 .../new-package-non-by-name/{ => pkgs/top-level}/all-packages.nix | 0 tests/no-eval/base/{ => pkgs/top-level}/all-packages.nix | 0 tests/no-eval/{ => pkgs/top-level}/all-packages.nix | 0 .../{ => pkgs/top-level}/all-packages.nix | 0 .../{ => pkgs/top-level}/all-packages.nix | 0 .../override-different-file/{ => pkgs/top-level}/all-packages.nix | 0 .../{ => base/pkgs/top-level}/all-packages.nix | 0 .../{base => pkgs/top-level}/all-packages.nix | 0 tests/override-empty-arg/{ => pkgs/top-level}/all-packages.nix | 0 .../{ => pkgs/top-level}/all-packages.nix | 0 tests/override-no-file/{ => pkgs/top-level}/all-packages.nix | 0 tests/override-non-path/{ => pkgs/top-level}/all-packages.nix | 0 tests/override-success/{ => pkgs/top-level}/all-packages.nix | 0 tests/package-variants/base/{ => pkgs/top-level}/all-packages.nix | 0 tests/package-variants/{ => pkgs/top-level}/all-packages.nix | 0 tests/sorted-order/{ => pkgs/top-level}/all-packages.nix | 0 tests/unknown-location/{ => pkgs/top-level}/all-packages.nix | 0 25 files changed, 0 insertions(+), 0 deletions(-) rename tests/aliases/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/alt-callPackage/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/callPackage-syntax/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/internalCallPackage/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/manual-definition/base/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/manual-definition/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/move-to-non-by-name/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/new-package-non-by-name/base/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/new-package-non-by-name/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/no-eval/base/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/no-eval/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/non-syntactical-callPackage-by-name/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/only-callPackage-derivations/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/override-different-file/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/override-empty-arg-gradual/{ => base/pkgs/top-level}/all-packages.nix (100%) rename tests/override-empty-arg-gradual/{base => pkgs/top-level}/all-packages.nix (100%) rename tests/override-empty-arg/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/override-no-call-package/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/override-no-file/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/override-non-path/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/override-success/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/package-variants/base/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/package-variants/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/sorted-order/{ => pkgs/top-level}/all-packages.nix (100%) rename tests/unknown-location/{ => pkgs/top-level}/all-packages.nix (100%) diff --git a/tests/aliases/all-packages.nix b/tests/aliases/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/aliases/all-packages.nix rename to tests/aliases/pkgs/top-level/all-packages.nix diff --git a/tests/alt-callPackage/all-packages.nix b/tests/alt-callPackage/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/alt-callPackage/all-packages.nix rename to tests/alt-callPackage/pkgs/top-level/all-packages.nix diff --git a/tests/callPackage-syntax/all-packages.nix b/tests/callPackage-syntax/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/callPackage-syntax/all-packages.nix rename to tests/callPackage-syntax/pkgs/top-level/all-packages.nix diff --git a/tests/internalCallPackage/all-packages.nix b/tests/internalCallPackage/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/internalCallPackage/all-packages.nix rename to tests/internalCallPackage/pkgs/top-level/all-packages.nix diff --git a/tests/manual-definition/base/all-packages.nix b/tests/manual-definition/base/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/manual-definition/base/all-packages.nix rename to tests/manual-definition/base/pkgs/top-level/all-packages.nix diff --git a/tests/manual-definition/all-packages.nix b/tests/manual-definition/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/manual-definition/all-packages.nix rename to tests/manual-definition/pkgs/top-level/all-packages.nix diff --git a/tests/move-to-non-by-name/all-packages.nix b/tests/move-to-non-by-name/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/move-to-non-by-name/all-packages.nix rename to tests/move-to-non-by-name/pkgs/top-level/all-packages.nix diff --git a/tests/new-package-non-by-name/base/all-packages.nix b/tests/new-package-non-by-name/base/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/new-package-non-by-name/base/all-packages.nix rename to tests/new-package-non-by-name/base/pkgs/top-level/all-packages.nix diff --git a/tests/new-package-non-by-name/all-packages.nix b/tests/new-package-non-by-name/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/new-package-non-by-name/all-packages.nix rename to tests/new-package-non-by-name/pkgs/top-level/all-packages.nix diff --git a/tests/no-eval/base/all-packages.nix b/tests/no-eval/base/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/no-eval/base/all-packages.nix rename to tests/no-eval/base/pkgs/top-level/all-packages.nix diff --git a/tests/no-eval/all-packages.nix b/tests/no-eval/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/no-eval/all-packages.nix rename to tests/no-eval/pkgs/top-level/all-packages.nix diff --git a/tests/non-syntactical-callPackage-by-name/all-packages.nix b/tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/non-syntactical-callPackage-by-name/all-packages.nix rename to tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix diff --git a/tests/only-callPackage-derivations/all-packages.nix b/tests/only-callPackage-derivations/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/only-callPackage-derivations/all-packages.nix rename to tests/only-callPackage-derivations/pkgs/top-level/all-packages.nix diff --git a/tests/override-different-file/all-packages.nix b/tests/override-different-file/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-different-file/all-packages.nix rename to tests/override-different-file/pkgs/top-level/all-packages.nix diff --git a/tests/override-empty-arg-gradual/all-packages.nix b/tests/override-empty-arg-gradual/base/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-empty-arg-gradual/all-packages.nix rename to tests/override-empty-arg-gradual/base/pkgs/top-level/all-packages.nix diff --git a/tests/override-empty-arg-gradual/base/all-packages.nix b/tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-empty-arg-gradual/base/all-packages.nix rename to tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix diff --git a/tests/override-empty-arg/all-packages.nix b/tests/override-empty-arg/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-empty-arg/all-packages.nix rename to tests/override-empty-arg/pkgs/top-level/all-packages.nix diff --git a/tests/override-no-call-package/all-packages.nix b/tests/override-no-call-package/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-no-call-package/all-packages.nix rename to tests/override-no-call-package/pkgs/top-level/all-packages.nix diff --git a/tests/override-no-file/all-packages.nix b/tests/override-no-file/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-no-file/all-packages.nix rename to tests/override-no-file/pkgs/top-level/all-packages.nix diff --git a/tests/override-non-path/all-packages.nix b/tests/override-non-path/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-non-path/all-packages.nix rename to tests/override-non-path/pkgs/top-level/all-packages.nix diff --git a/tests/override-success/all-packages.nix b/tests/override-success/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-success/all-packages.nix rename to tests/override-success/pkgs/top-level/all-packages.nix diff --git a/tests/package-variants/base/all-packages.nix b/tests/package-variants/base/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/package-variants/base/all-packages.nix rename to tests/package-variants/base/pkgs/top-level/all-packages.nix diff --git a/tests/package-variants/all-packages.nix b/tests/package-variants/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/package-variants/all-packages.nix rename to tests/package-variants/pkgs/top-level/all-packages.nix diff --git a/tests/sorted-order/all-packages.nix b/tests/sorted-order/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/sorted-order/all-packages.nix rename to tests/sorted-order/pkgs/top-level/all-packages.nix diff --git a/tests/unknown-location/all-packages.nix b/tests/unknown-location/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/unknown-location/all-packages.nix rename to tests/unknown-location/pkgs/top-level/all-packages.nix From 7c75c015b94b3fa8267091a1719b10c8eaed677d Mon Sep 17 00:00:00 2001 From: Will Bush Date: Wed, 3 Apr 2024 21:20:56 -0500 Subject: [PATCH 2/3] Fix relative paths in all-packages.nix files and expected outputs --- tests/alt-callPackage/expected | 2 +- .../pkgs/top-level/all-packages.nix | 4 ++-- .../base/pkgs/top-level/all-packages.nix | 2 +- tests/manual-definition/expected | 8 ++++---- .../pkgs/top-level/all-packages.nix | 4 ++-- tests/mock-nixpkgs.nix | 4 ++-- tests/move-to-non-by-name/expected | 8 ++++---- .../pkgs/top-level/all-packages.nix | 4 ++-- tests/new-package-non-by-name/expected | 8 ++++---- .../pkgs/top-level/all-packages.nix | 4 ++-- tests/non-syntactical-callPackage-by-name/expected | 2 +- .../pkgs/top-level/all-packages.nix | 2 +- tests/override-different-file/expected | 6 +++--- .../pkgs/top-level/all-packages.nix | 2 +- .../base/pkgs/top-level/all-packages.nix | 2 +- .../pkgs/top-level/all-packages.nix | 2 +- tests/override-empty-arg/expected | 4 ++-- .../pkgs/top-level/all-packages.nix | 2 +- tests/override-no-call-package/expected | 2 +- tests/override-no-file/expected | 2 +- tests/override-non-path/expected | 2 +- .../override-success/pkgs/top-level/all-packages.nix | 2 +- .../base/pkgs/top-level/all-packages.nix | 2 +- .../package-variants/pkgs/top-level/all-packages.nix | 4 ++-- tests/sorted-order/expected | 12 ++++++------ tests/sorted-order/pkgs/top-level/all-packages.nix | 4 ++-- 26 files changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/alt-callPackage/expected b/tests/alt-callPackage/expected index 1d92e65..741fc8e 100644 --- a/tests/alt-callPackage/expected +++ b/tests/alt-callPackage/expected @@ -2,7 +2,7 @@ foo = callPackage ./pkgs/by-name/fo/foo/package.nix { /* ... */ }; - However, in this PR, a different `callPackage` is used. See the definition in all-packages.nix:5: + However, in this PR, a different `callPackage` is used. See the definition in pkgs/top-level/all-packages.nix:5: foo = self.alt.callPackage ({ }: self.someDrv) { }; diff --git a/tests/internalCallPackage/pkgs/top-level/all-packages.nix b/tests/internalCallPackage/pkgs/top-level/all-packages.nix index 3fbe2d5..0422aba 100644 --- a/tests/internalCallPackage/pkgs/top-level/all-packages.nix +++ b/tests/internalCallPackage/pkgs/top-level/all-packages.nix @@ -1,4 +1,4 @@ self: super: { - foo = self._internalCallByNamePackageFile ./foo.nix; - bar = self._internalCallByNamePackageFile ./foo.nix; + foo = self._internalCallByNamePackageFile ./../../foo.nix; + bar = self._internalCallByNamePackageFile ./../../foo.nix; } diff --git a/tests/manual-definition/base/pkgs/top-level/all-packages.nix b/tests/manual-definition/base/pkgs/top-level/all-packages.nix index 75efb59..8209b65 100644 --- a/tests/manual-definition/base/pkgs/top-level/all-packages.nix +++ b/tests/manual-definition/base/pkgs/top-level/all-packages.nix @@ -1,7 +1,7 @@ self: super: { nonAttributeSet = null; nonCallPackage = self.someDrv; - internalCallByName = self._internalCallByNamePackageFile ./some-pkg.nix; + internalCallByName = self._internalCallByNamePackageFile ./../../some-pkg.nix; nonDerivation = self.callPackage ({ }: { }) { }; onlyMove = self.callPackage ({ someDrv }: someDrv) { }; diff --git a/tests/manual-definition/expected b/tests/manual-definition/expected index 4d906ec..3efca0a 100644 --- a/tests/manual-definition/expected +++ b/tests/manual-definition/expected @@ -2,9 +2,9 @@ noEval = callPackage ./pkgs/by-name/no/noEval/package.nix { /* ... */ }; - However, in this PR, the second argument is empty. See the definition in all-packages.nix:9: + However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:9: - noEval = self.callPackage ./pkgs/by-name/no/noEval/package.nix { }; + noEval = self.callPackage ./../by-name/no/noEval/package.nix { }; Such a definition is provided automatically and therefore not necessary. Please remove it. @@ -12,9 +12,9 @@ onlyMove = callPackage ./pkgs/by-name/on/onlyMove/package.nix { /* ... */ }; - However, in this PR, the second argument is empty. See the definition in all-packages.nix:7: + However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:7: - onlyMove = self.callPackage ./pkgs/by-name/on/onlyMove/package.nix { }; + onlyMove = self.callPackage ./../by-name/on/onlyMove/package.nix { }; Such a definition is provided automatically and therefore not necessary. Please remove it. diff --git a/tests/manual-definition/pkgs/top-level/all-packages.nix b/tests/manual-definition/pkgs/top-level/all-packages.nix index 07b2caa..3e14d87 100644 --- a/tests/manual-definition/pkgs/top-level/all-packages.nix +++ b/tests/manual-definition/pkgs/top-level/all-packages.nix @@ -4,7 +4,7 @@ self: super: { internalCallByName = self.callPackage ({ someDrv }: someDrv) { }; nonDerivation = self.callPackage ({ someDrv }: someDrv) { }; - onlyMove = self.callPackage ./pkgs/by-name/on/onlyMove/package.nix { }; + onlyMove = self.callPackage ./../by-name/on/onlyMove/package.nix { }; - noEval = self.callPackage ./pkgs/by-name/no/noEval/package.nix { }; + noEval = self.callPackage ./../by-name/no/noEval/package.nix { }; } diff --git a/tests/mock-nixpkgs.nix b/tests/mock-nixpkgs.nix index fbd51f6..bba84db 100644 --- a/tests/mock-nixpkgs.nix +++ b/tests/mock-nixpkgs.nix @@ -81,8 +81,8 @@ let # A list optionally containing the `all-packages.nix` file from the test case as an overlay optionalAllPackagesOverlay = - if builtins.pathExists (root + "/all-packages.nix") then - [ (import (root + "/all-packages.nix")) ] + if builtins.pathExists (root + "/pkgs/top-level/all-packages.nix") then + [ (import (root + "/pkgs/top-level/all-packages.nix")) ] else [ ]; diff --git a/tests/move-to-non-by-name/expected b/tests/move-to-non-by-name/expected index 123e24d..0dc6989 100644 --- a/tests/move-to-non-by-name/expected +++ b/tests/move-to-non-by-name/expected @@ -1,13 +1,13 @@ -- Attribute `pkgs.foo1` was previously defined in pkgs/by-name/fo/foo1/package.nix, but is now manually defined as `callPackage ... { /* ... */ }` in all-packages.nix. +- Attribute `pkgs.foo1` was previously defined in pkgs/by-name/fo/foo1/package.nix, but is now manually defined as `callPackage ... { /* ... */ }` in pkgs/top-level/all-packages.nix. Please move the package back and remove the manual `callPackage`. -- Attribute `pkgs.foo2` was previously defined in pkgs/by-name/fo/foo2/package.nix, but is now manually defined as `callPackage ./without-config.nix { /* ... */ }` in all-packages.nix. +- Attribute `pkgs.foo2` was previously defined in pkgs/by-name/fo/foo2/package.nix, but is now manually defined as `callPackage ./without-config.nix { /* ... */ }` in pkgs/top-level/all-packages.nix. Please move the package back and remove the manual `callPackage`. -- Attribute `pkgs.foo3` was previously defined in pkgs/by-name/fo/foo3/package.nix, but is now manually defined as `callPackage ... { ... }` in all-packages.nix. +- Attribute `pkgs.foo3` was previously defined in pkgs/by-name/fo/foo3/package.nix, but is now manually defined as `callPackage ... { ... }` in pkgs/top-level/all-packages.nix. While the manual `callPackage` is still needed, it's not necessary to move the package files. -- Attribute `pkgs.foo4` was previously defined in pkgs/by-name/fo/foo4/package.nix, but is now manually defined as `callPackage ./with-config.nix { ... }` in all-packages.nix. +- Attribute `pkgs.foo4` was previously defined in pkgs/by-name/fo/foo4/package.nix, but is now manually defined as `callPackage ./with-config.nix { ... }` in pkgs/top-level/all-packages.nix. While the manual `callPackage` is still needed, it's not necessary to move the package files. This PR introduces additional instances of discouraged patterns as listed above. Merging is discouraged but would not break the base branch. diff --git a/tests/move-to-non-by-name/pkgs/top-level/all-packages.nix b/tests/move-to-non-by-name/pkgs/top-level/all-packages.nix index 16834c4..cc25378 100644 --- a/tests/move-to-non-by-name/pkgs/top-level/all-packages.nix +++ b/tests/move-to-non-by-name/pkgs/top-level/all-packages.nix @@ -1,10 +1,10 @@ self: super: { foo1 = self.callPackage ({ someDrv }: someDrv) { }; - foo2 = self.callPackage ./without-config.nix { }; + foo2 = self.callPackage ./../../without-config.nix { }; foo3 = self.callPackage ({ someDrv, enableFoo }: someDrv) { enableFoo = null; }; - foo4 = self.callPackage ./with-config.nix { + foo4 = self.callPackage ./../../with-config.nix { enableFoo = null; }; } diff --git a/tests/new-package-non-by-name/expected b/tests/new-package-non-by-name/expected index 92668a2..43e9279 100644 --- a/tests/new-package-non-by-name/expected +++ b/tests/new-package-non-by-name/expected @@ -1,21 +1,21 @@ - Attribute `pkgs.new1` is a new top-level package using `pkgs.callPackage ... { /* ... */ }`. Please define it in pkgs/by-name/ne/new1/package.nix instead. See `pkgs/by-name/README.md` for more details. - Since the second `callPackage` argument is `{ }`, no manual `callPackage` in all-packages.nix is needed anymore. + Since the second `callPackage` argument is `{ }`, no manual `callPackage` in pkgs/top-level/all-packages.nix is needed anymore. - Attribute `pkgs.new2` is a new top-level package using `pkgs.callPackage ./without-config.nix { /* ... */ }`. Please define it in pkgs/by-name/ne/new2/package.nix instead. See `pkgs/by-name/README.md` for more details. - Since the second `callPackage` argument is `{ }`, no manual `callPackage` in all-packages.nix is needed anymore. + Since the second `callPackage` argument is `{ }`, no manual `callPackage` in pkgs/top-level/all-packages.nix is needed anymore. - Attribute `pkgs.new3` is a new top-level package using `pkgs.callPackage ... { /* ... */ }`. Please define it in pkgs/by-name/ne/new3/package.nix instead. See `pkgs/by-name/README.md` for more details. - Since the second `callPackage` argument is not `{ }`, the manual `callPackage` in all-packages.nix is still needed. + Since the second `callPackage` argument is not `{ }`, the manual `callPackage` in pkgs/top-level/all-packages.nix is still needed. - Attribute `pkgs.new4` is a new top-level package using `pkgs.callPackage ./with-config.nix { /* ... */ }`. Please define it in pkgs/by-name/ne/new4/package.nix instead. See `pkgs/by-name/README.md` for more details. - Since the second `callPackage` argument is not `{ }`, the manual `callPackage` in all-packages.nix is still needed. + Since the second `callPackage` argument is not `{ }`, the manual `callPackage` in pkgs/top-level/all-packages.nix is still needed. This PR introduces additional instances of discouraged patterns as listed above. Merging is discouraged but would not break the base branch. diff --git a/tests/new-package-non-by-name/pkgs/top-level/all-packages.nix b/tests/new-package-non-by-name/pkgs/top-level/all-packages.nix index 069119a..2e5be38 100644 --- a/tests/new-package-non-by-name/pkgs/top-level/all-packages.nix +++ b/tests/new-package-non-by-name/pkgs/top-level/all-packages.nix @@ -1,11 +1,11 @@ self: super: { before = self.callPackage ({ someDrv }: someDrv) { }; new1 = self.callPackage ({ someDrv }: someDrv) { }; - new2 = self.callPackage ./without-config.nix { }; + new2 = self.callPackage ./../../without-config.nix { }; new3 = self.callPackage ({ someDrv, enableNew }: someDrv) { enableNew = null; }; - new4 = self.callPackage ./with-config.nix { + new4 = self.callPackage ./../../with-config.nix { enableNew = null; }; } diff --git a/tests/non-syntactical-callPackage-by-name/expected b/tests/non-syntactical-callPackage-by-name/expected index e09e931..7991261 100644 --- a/tests/non-syntactical-callPackage-by-name/expected +++ b/tests/non-syntactical-callPackage-by-name/expected @@ -2,7 +2,7 @@ foo = callPackage ./pkgs/by-name/fo/foo/package.nix { /* ... */ }; - However, in this PR, it isn't defined that way. See the definition in all-packages.nix:4 + However, in this PR, it isn't defined that way. See the definition in pkgs/top-level/all-packages.nix:4 foo = self.bar; diff --git a/tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix b/tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix index 3e0ea20..7c0e55f 100644 --- a/tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix +++ b/tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix @@ -1,6 +1,6 @@ self: super: { - bar = (x: x) self.callPackage ./pkgs/by-name/fo/foo/package.nix { someFlag = true; }; + bar = (x: x) self.callPackage ./../by-name/fo/foo/package.nix { someFlag = true; }; foo = self.bar; } diff --git a/tests/override-different-file/expected b/tests/override-different-file/expected index 16292c0..8b18b9a 100644 --- a/tests/override-different-file/expected +++ b/tests/override-different-file/expected @@ -1,9 +1,9 @@ - Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like - nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; + nonDerivation = callPackage ./../by-name/no/nonDerivation/package.nix { /* ... */ }; - However, in this PR, the first `callPackage` argument is the wrong path. See the definition in all-packages.nix:2: + However, in this PR, the first `callPackage` argument is the wrong path. See the definition in pkgs/top-level/all-packages.nix:2: - nonDerivation = callPackage ./someDrv.nix { /* ... */ }; + nonDerivation = callPackage ./../../someDrv.nix { /* ... */ }; This PR introduces the problems listed above. Please fix them before merging, otherwise the base branch would break. diff --git a/tests/override-different-file/pkgs/top-level/all-packages.nix b/tests/override-different-file/pkgs/top-level/all-packages.nix index 8bedb90..e196d26 100644 --- a/tests/override-different-file/pkgs/top-level/all-packages.nix +++ b/tests/override-different-file/pkgs/top-level/all-packages.nix @@ -1,3 +1,3 @@ self: super: { - nonDerivation = self.callPackage ./someDrv.nix { }; + nonDerivation = self.callPackage ./../../someDrv.nix { }; } diff --git a/tests/override-empty-arg-gradual/base/pkgs/top-level/all-packages.nix b/tests/override-empty-arg-gradual/base/pkgs/top-level/all-packages.nix index d369dd7..eaf7e92 100644 --- a/tests/override-empty-arg-gradual/base/pkgs/top-level/all-packages.nix +++ b/tests/override-empty-arg-gradual/base/pkgs/top-level/all-packages.nix @@ -1,3 +1,3 @@ self: super: { - nonDerivation = self.callPackage ./pkgs/by-name/no/nonDerivation/package.nix { }; + nonDerivation = self.callPackage ./../by-name/no/nonDerivation/package.nix { }; } diff --git a/tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix b/tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix index d369dd7..eaf7e92 100644 --- a/tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix +++ b/tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix @@ -1,3 +1,3 @@ self: super: { - nonDerivation = self.callPackage ./pkgs/by-name/no/nonDerivation/package.nix { }; + nonDerivation = self.callPackage ./../by-name/no/nonDerivation/package.nix { }; } diff --git a/tests/override-empty-arg/expected b/tests/override-empty-arg/expected index f3306aa..3f141bb 100644 --- a/tests/override-empty-arg/expected +++ b/tests/override-empty-arg/expected @@ -2,9 +2,9 @@ nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; - However, in this PR, the second argument is empty. See the definition in all-packages.nix:2: + However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:2: - nonDerivation = self.callPackage ./pkgs/by-name/no/nonDerivation/package.nix { }; + nonDerivation = self.callPackage ./../by-name/no/nonDerivation/package.nix { }; Such a definition is provided automatically and therefore not necessary. Please remove it. diff --git a/tests/override-empty-arg/pkgs/top-level/all-packages.nix b/tests/override-empty-arg/pkgs/top-level/all-packages.nix index d369dd7..eaf7e92 100644 --- a/tests/override-empty-arg/pkgs/top-level/all-packages.nix +++ b/tests/override-empty-arg/pkgs/top-level/all-packages.nix @@ -1,3 +1,3 @@ self: super: { - nonDerivation = self.callPackage ./pkgs/by-name/no/nonDerivation/package.nix { }; + nonDerivation = self.callPackage ./../by-name/no/nonDerivation/package.nix { }; } diff --git a/tests/override-no-call-package/expected b/tests/override-no-call-package/expected index d91d58d..ae42a17 100644 --- a/tests/override-no-call-package/expected +++ b/tests/override-no-call-package/expected @@ -2,7 +2,7 @@ nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; - However, in this PR, it isn't defined that way. See the definition in all-packages.nix:2 + However, in this PR, it isn't defined that way. See the definition in pkgs/top-level/all-packages.nix:2 nonDerivation = self.someDrv; diff --git a/tests/override-no-file/expected b/tests/override-no-file/expected index 807c440..0f26b78 100644 --- a/tests/override-no-file/expected +++ b/tests/override-no-file/expected @@ -2,7 +2,7 @@ nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; - However, in this PR, the first `callPackage` argument is not a path. See the definition in all-packages.nix:2: + However, in this PR, the first `callPackage` argument is not a path. See the definition in pkgs/top-level/all-packages.nix:2: nonDerivation = self.callPackage ({ someDrv }: someDrv) { }; diff --git a/tests/override-non-path/expected b/tests/override-non-path/expected index 4adbaf6..ae4e7e8 100644 --- a/tests/override-non-path/expected +++ b/tests/override-non-path/expected @@ -2,7 +2,7 @@ foo = callPackage ./pkgs/by-name/fo/foo/package.nix { /* ... */ }; - However, in this PR, the first `callPackage` argument is not a path. See the definition in all-packages.nix:3: + However, in this PR, the first `callPackage` argument is not a path. See the definition in pkgs/top-level/all-packages.nix:3: foo = self.callPackage ({ someDrv, someFlag }: someDrv) { someFlag = true; }; diff --git a/tests/override-success/pkgs/top-level/all-packages.nix b/tests/override-success/pkgs/top-level/all-packages.nix index 6b32375..bf01a4b 100644 --- a/tests/override-success/pkgs/top-level/all-packages.nix +++ b/tests/override-success/pkgs/top-level/all-packages.nix @@ -1,5 +1,5 @@ self: super: { - foo = self.callPackage ./pkgs/by-name/fo/foo/package.nix { + foo = self.callPackage ./../by-name/fo/foo/package.nix { enableBar = true; }; } diff --git a/tests/package-variants/base/pkgs/top-level/all-packages.nix b/tests/package-variants/base/pkgs/top-level/all-packages.nix index 7346043..d786f73 100644 --- a/tests/package-variants/base/pkgs/top-level/all-packages.nix +++ b/tests/package-variants/base/pkgs/top-level/all-packages.nix @@ -1,3 +1,3 @@ self: super: { - foo-variant-unvarianted = self.callPackage ./pkgs/by-name/fo/foo/package.nix { }; + foo-variant-unvarianted = self.callPackage ./../by-name/fo/foo/package.nix { }; } diff --git a/tests/package-variants/pkgs/top-level/all-packages.nix b/tests/package-variants/pkgs/top-level/all-packages.nix index 85f8c61..86d7628 100644 --- a/tests/package-variants/pkgs/top-level/all-packages.nix +++ b/tests/package-variants/pkgs/top-level/all-packages.nix @@ -1,5 +1,5 @@ self: super: { - foo-variant-unvarianted = self.callPackage ./package.nix { }; + foo-variant-unvarianted = self.callPackage ./../../package.nix { }; - foo-variant-new = self.callPackage ./pkgs/by-name/fo/foo/package.nix { }; + foo-variant-new = self.callPackage ./../by-name/fo/foo/package.nix { }; } diff --git a/tests/sorted-order/expected b/tests/sorted-order/expected index 8a8104b..4150212 100644 --- a/tests/sorted-order/expected +++ b/tests/sorted-order/expected @@ -2,30 +2,30 @@ a = callPackage ./pkgs/by-name/a/a/package.nix { /* ... */ }; - However, in this PR, the second argument is empty. See the definition in all-packages.nix:2: + However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:2: - a = self.callPackage ./pkgs/by-name/a/a/package.nix { }; + a = self.callPackage ./../by-name/a/a/package.nix { }; Such a definition is provided automatically and therefore not necessary. Please remove it. - Attribute `pkgs.b` is a new top-level package using `pkgs.callPackage ... { /* ... */ }`. Please define it in pkgs/by-name/b/b/package.nix instead. See `pkgs/by-name/README.md` for more details. - Since the second `callPackage` argument is `{ }`, no manual `callPackage` in all-packages.nix is needed anymore. + Since the second `callPackage` argument is `{ }`, no manual `callPackage` in pkgs/top-level/all-packages.nix is needed anymore. - Because pkgs/by-name/c/c exists, the attribute `pkgs.c` must be defined like c = callPackage ./pkgs/by-name/c/c/package.nix { /* ... */ }; - However, in this PR, the second argument is empty. See the definition in all-packages.nix:4: + However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:4: - c = self.callPackage ./pkgs/by-name/c/c/package.nix { }; + c = self.callPackage ./../by-name/c/c/package.nix { }; Such a definition is provided automatically and therefore not necessary. Please remove it. - Attribute `pkgs.d` is a new top-level package using `pkgs.callPackage ... { /* ... */ }`. Please define it in pkgs/by-name/d/d/package.nix instead. See `pkgs/by-name/README.md` for more details. - Since the second `callPackage` argument is `{ }`, no manual `callPackage` in all-packages.nix is needed anymore. + Since the second `callPackage` argument is `{ }`, no manual `callPackage` in pkgs/top-level/all-packages.nix is needed anymore. This PR introduces additional instances of discouraged patterns as listed above. Merging is discouraged but would not break the base branch. diff --git a/tests/sorted-order/pkgs/top-level/all-packages.nix b/tests/sorted-order/pkgs/top-level/all-packages.nix index 688f52b..2fb8d52 100644 --- a/tests/sorted-order/pkgs/top-level/all-packages.nix +++ b/tests/sorted-order/pkgs/top-level/all-packages.nix @@ -1,6 +1,6 @@ self: super: { - a = self.callPackage ./pkgs/by-name/a/a/package.nix { }; + a = self.callPackage ./../by-name/a/a/package.nix { }; b = self.callPackage ({ someDrv }: someDrv) { }; - c = self.callPackage ./pkgs/by-name/c/c/package.nix { }; + c = self.callPackage ./../by-name/c/c/package.nix { }; d = self.callPackage ({ someDrv }: someDrv) { }; } From c460d5e3979d8f80c9c4caed5f275ddc19431d76 Mon Sep 17 00:00:00 2001 From: Will Bush Date: Wed, 3 Apr 2024 21:51:59 -0500 Subject: [PATCH 3/3] Update errors paths to be relative to the expression file --- src/eval.rs | 12 ++++---- src/nixpkgs_problem.rs | 30 +++++++++---------- tests/alt-callPackage/expected | 2 +- tests/manual-definition/expected | 4 +-- .../expected | 2 +- tests/override-empty-arg/expected | 2 +- tests/override-no-call-package/expected | 2 +- tests/override-no-file/expected | 2 +- tests/override-non-path/expected | 2 +- tests/sorted-order/expected | 4 +-- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index 37a1cb1..ff8692d 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -344,9 +344,12 @@ fn by_name_override( location: Location, relative_location_file: RelativePathBuf, ) -> validation::Validation> { + let expected_package_path = structure::relative_file_for_package(attribute_name); + let to_problem = |kind| { NixpkgsProblem::ByNameOverride(ByNameOverrideError { package_name: attribute_name.to_owned(), + expected_package_path: expected_package_path.to_owned(), file: relative_location_file, line: location.line, column: location.column, @@ -364,14 +367,11 @@ fn by_name_override( (false, Some(_)) => to_problem(ByNameOverrideErrorKind::NonToplevelCallPackage).into(), // Something like ` = pkgs.callPackage ...` (true, Some(syntactic_call_package)) => { - if let Some(actual_package_file) = syntactic_call_package.relative_path { - let expected_package_file = structure::relative_file_for_package(attribute_name); - - if actual_package_file != expected_package_file { + if let Some(actual_package_path) = syntactic_call_package.relative_path { + if actual_package_path != expected_package_path { // Wrong path to_problem(ByNameOverrideErrorKind::WrongCallPackagePath { - actual_path: actual_package_file, - expected_path: expected_package_file, + actual_path: actual_package_path, }) .into() } else { diff --git a/src/nixpkgs_problem.rs b/src/nixpkgs_problem.rs index 3f1e942..b272b9e 100644 --- a/src/nixpkgs_problem.rs +++ b/src/nixpkgs_problem.rs @@ -77,6 +77,7 @@ pub enum ByNameErrorKind { #[derive(Clone)] pub struct ByNameOverrideError { pub package_name: String, + pub expected_package_path: RelativePathBuf, pub file: RelativePathBuf, pub line: usize, pub column: usize, @@ -88,10 +89,7 @@ pub struct ByNameOverrideError { pub enum ByNameOverrideErrorKind { NonSyntacticCallPackage, NonToplevelCallPackage, - WrongCallPackagePath { - actual_path: RelativePathBuf, - expected_path: RelativePathBuf, - }, + WrongCallPackagePath { actual_path: RelativePathBuf }, EmptyArgument, NonPath, } @@ -234,6 +232,7 @@ impl fmt::Display for NixpkgsProblem { } NixpkgsProblem::ByNameOverride(ByNameOverrideError { package_name, + expected_package_path, file, line, column, @@ -241,40 +240,41 @@ impl fmt::Display for NixpkgsProblem { kind, }) => { let relative_package_dir = structure::relative_dir_for_package(package_name); - let relative_package_file = structure::relative_file_for_package(package_name); + let expected_path_expr = create_path_expr(file, expected_package_path); let indented_definition = indent_definition(*column, definition.clone()); match kind { - ByNameOverrideErrorKind::NonSyntacticCallPackage => + ByNameOverrideErrorKind::NonSyntacticCallPackage => { + writedoc!( f, " - Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like - {package_name} = callPackage ./{relative_package_file} {{ /* ... */ }}; + {package_name} = callPackage {expected_path_expr} {{ /* ... */ }}; However, in this PR, it isn't defined that way. See the definition in {file}:{line} {indented_definition} ", - ), + ) + } ByNameOverrideErrorKind::NonToplevelCallPackage => writedoc!( f, " - Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like - {package_name} = callPackage ./{relative_package_file} {{ /* ... */ }}; + {package_name} = callPackage {expected_path_expr} {{ /* ... */ }}; However, in this PR, a different `callPackage` is used. See the definition in {file}:{line}: {indented_definition} ", ), - ByNameOverrideErrorKind::WrongCallPackagePath { actual_path, expected_path } => { - let expected_path_expr = create_path_expr(file, expected_path); + ByNameOverrideErrorKind::WrongCallPackagePath { actual_path } => { let actual_path_expr = create_path_expr(file, actual_path); - writedoc! { + writedoc!( f, " - Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like @@ -285,7 +285,7 @@ impl fmt::Display for NixpkgsProblem { {package_name} = callPackage {actual_path_expr} {{ /* ... */ }}; ", - } + ) } ByNameOverrideErrorKind::EmptyArgument => writedoc!( @@ -293,7 +293,7 @@ impl fmt::Display for NixpkgsProblem { " - Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like - {package_name} = callPackage ./{relative_package_file} {{ /* ... */ }}; + {package_name} = callPackage {expected_path_expr} {{ /* ... */ }}; However, in this PR, the second argument is empty. See the definition in {file}:{line}: @@ -308,7 +308,7 @@ impl fmt::Display for NixpkgsProblem { " - Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like - {package_name} = callPackage ./{relative_package_file} {{ /* ... */ }}; + {package_name} = callPackage {expected_path_expr} {{ /* ... */ }}; However, in this PR, the first `callPackage` argument is not a path. See the definition in {file}:{line}: diff --git a/tests/alt-callPackage/expected b/tests/alt-callPackage/expected index 741fc8e..0435e03 100644 --- a/tests/alt-callPackage/expected +++ b/tests/alt-callPackage/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/fo/foo exists, the attribute `pkgs.foo` must be defined like - foo = callPackage ./pkgs/by-name/fo/foo/package.nix { /* ... */ }; + foo = callPackage ./../by-name/fo/foo/package.nix { /* ... */ }; However, in this PR, a different `callPackage` is used. See the definition in pkgs/top-level/all-packages.nix:5: diff --git a/tests/manual-definition/expected b/tests/manual-definition/expected index 3efca0a..915cb8c 100644 --- a/tests/manual-definition/expected +++ b/tests/manual-definition/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/no/noEval exists, the attribute `pkgs.noEval` must be defined like - noEval = callPackage ./pkgs/by-name/no/noEval/package.nix { /* ... */ }; + noEval = callPackage ./../by-name/no/noEval/package.nix { /* ... */ }; However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:9: @@ -10,7 +10,7 @@ - Because pkgs/by-name/on/onlyMove exists, the attribute `pkgs.onlyMove` must be defined like - onlyMove = callPackage ./pkgs/by-name/on/onlyMove/package.nix { /* ... */ }; + onlyMove = callPackage ./../by-name/on/onlyMove/package.nix { /* ... */ }; However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:7: diff --git a/tests/non-syntactical-callPackage-by-name/expected b/tests/non-syntactical-callPackage-by-name/expected index 7991261..01cbb1b 100644 --- a/tests/non-syntactical-callPackage-by-name/expected +++ b/tests/non-syntactical-callPackage-by-name/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/fo/foo exists, the attribute `pkgs.foo` must be defined like - foo = callPackage ./pkgs/by-name/fo/foo/package.nix { /* ... */ }; + foo = callPackage ./../by-name/fo/foo/package.nix { /* ... */ }; However, in this PR, it isn't defined that way. See the definition in pkgs/top-level/all-packages.nix:4 diff --git a/tests/override-empty-arg/expected b/tests/override-empty-arg/expected index 3f141bb..7ab86c5 100644 --- a/tests/override-empty-arg/expected +++ b/tests/override-empty-arg/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like - nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; + nonDerivation = callPackage ./../by-name/no/nonDerivation/package.nix { /* ... */ }; However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:2: diff --git a/tests/override-no-call-package/expected b/tests/override-no-call-package/expected index ae42a17..686c84f 100644 --- a/tests/override-no-call-package/expected +++ b/tests/override-no-call-package/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like - nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; + nonDerivation = callPackage ./../by-name/no/nonDerivation/package.nix { /* ... */ }; However, in this PR, it isn't defined that way. See the definition in pkgs/top-level/all-packages.nix:2 diff --git a/tests/override-no-file/expected b/tests/override-no-file/expected index 0f26b78..803eef6 100644 --- a/tests/override-no-file/expected +++ b/tests/override-no-file/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like - nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }; + nonDerivation = callPackage ./../by-name/no/nonDerivation/package.nix { /* ... */ }; However, in this PR, the first `callPackage` argument is not a path. See the definition in pkgs/top-level/all-packages.nix:2: diff --git a/tests/override-non-path/expected b/tests/override-non-path/expected index ae4e7e8..0460473 100644 --- a/tests/override-non-path/expected +++ b/tests/override-non-path/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/fo/foo exists, the attribute `pkgs.foo` must be defined like - foo = callPackage ./pkgs/by-name/fo/foo/package.nix { /* ... */ }; + foo = callPackage ./../by-name/fo/foo/package.nix { /* ... */ }; However, in this PR, the first `callPackage` argument is not a path. See the definition in pkgs/top-level/all-packages.nix:3: diff --git a/tests/sorted-order/expected b/tests/sorted-order/expected index 4150212..8cdd2c7 100644 --- a/tests/sorted-order/expected +++ b/tests/sorted-order/expected @@ -1,6 +1,6 @@ - Because pkgs/by-name/a/a exists, the attribute `pkgs.a` must be defined like - a = callPackage ./pkgs/by-name/a/a/package.nix { /* ... */ }; + a = callPackage ./../by-name/a/a/package.nix { /* ... */ }; However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:2: @@ -15,7 +15,7 @@ - Because pkgs/by-name/c/c exists, the attribute `pkgs.c` must be defined like - c = callPackage ./pkgs/by-name/c/c/package.nix { /* ... */ }; + c = callPackage ./../by-name/c/c/package.nix { /* ... */ }; However, in this PR, the second argument is empty. See the definition in pkgs/top-level/all-packages.nix:4: