about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2024-01-30 22:35:04 +0100
committerSilvan Mosberger <silvan.mosberger@tweag.io>2024-01-30 22:45:18 +0100
commit7d1f0a4cd4ac9b224ace12222107882d869adce0 (patch)
tree24ad8e7ae0ed36406e412c661a9c28b1fbfbbfda
parent46da6c5c1f8daee0be796f27f1307b39e45fb5cf (diff)
tests.nixpkgs-check-by-name: Allow new package variants
-rw-r--r--pkgs/test/nixpkgs-check-by-name/src/eval.rs23
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/all-packages.nix5
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/all-packages.nix3
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/default.nix1
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/pkgs/by-name/fo/foo/package.nix1
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/default.nix1
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/package.nix1
-rw-r--r--pkgs/test/nixpkgs-check-by-name/tests/package-variants/pkgs/by-name/fo/foo/package.nix1
8 files changed, 35 insertions, 1 deletions
diff --git a/pkgs/test/nixpkgs-check-by-name/src/eval.rs b/pkgs/test/nixpkgs-check-by-name/src/eval.rs
index 85c1f2812a68e..53714886fa873 100644
--- a/pkgs/test/nixpkgs-check-by-name/src/eval.rs
+++ b/pkgs/test/nixpkgs-check-by-name/src/eval.rs
@@ -1,6 +1,7 @@
 use crate::nixpkgs_problem::NixpkgsProblem;
 use crate::ratchet;
 use crate::structure;
+use crate::utils;
 use crate::validation::ResultIteratorExt;
 use crate::validation::{self, Validation::Success};
 use crate::NixFileCache;
@@ -223,7 +224,27 @@ pub fn check_values(
                                     nixpkgs_path,
                                 )? {
                                     None => Success(NonApplicable),
-                                    Some(call_package_argument_info) => Success(Loose(call_package_argument_info))
+                                    Some(call_package_argument_info) => {
+                                        if let Some(ref rel_path) = call_package_argument_info.relative_path {
+                                            if rel_path.starts_with(utils::BASE_SUBPATH) {
+                                                // Package variants of by-name packages are explicitly allowed according to RFC 140
+                                                // https://github.com/NixOS/rfcs/blob/master/rfcs/0140-simple-package-paths.md#package-variants:
+                                                //
+                                                // foo-variant = callPackage ../by-name/fo/foo/package.nix {
+                                                //   someFlag = true;
+                                                // }
+                                                //
+                                                // While such definitions could be moved to `pkgs/by-name` by using
+                                                // `.override { someFlag = true; }` instead, this changes the semantics in
+                                                // relation with overlays.
+                                                Success(NonApplicable)
+                                            } else {
+                                                Success(Loose(call_package_argument_info))
+                                            }
+                                        } else {
+                                            Success(Loose(call_package_argument_info))
+                                        }
+                                    },
                                 },
                         },
                     };
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/all-packages.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/all-packages.nix
new file mode 100644
index 0000000000000..85f8c6138c5c2
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/all-packages.nix
@@ -0,0 +1,5 @@
+self: super: {
+  foo-variant-unvarianted = self.callPackage ./package.nix { };
+
+  foo-variant-new = self.callPackage ./pkgs/by-name/fo/foo/package.nix { };
+}
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/all-packages.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/all-packages.nix
new file mode 100644
index 0000000000000..734604360073b
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/all-packages.nix
@@ -0,0 +1,3 @@
+self: super: {
+  foo-variant-unvarianted = self.callPackage ./pkgs/by-name/fo/foo/package.nix { };
+}
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/default.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/default.nix
new file mode 100644
index 0000000000000..861260cdca4b2
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/default.nix
@@ -0,0 +1 @@
+import <test-nixpkgs> { root = ./.; }
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/pkgs/by-name/fo/foo/package.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/pkgs/by-name/fo/foo/package.nix
new file mode 100644
index 0000000000000..a1b92efbbadb9
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/base/pkgs/by-name/fo/foo/package.nix
@@ -0,0 +1 @@
+{ someDrv }: someDrv
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/default.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/default.nix
new file mode 100644
index 0000000000000..861260cdca4b2
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/default.nix
@@ -0,0 +1 @@
+import <test-nixpkgs> { root = ./.; }
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/package.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/package.nix
new file mode 100644
index 0000000000000..a1b92efbbadb9
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/package.nix
@@ -0,0 +1 @@
+{ someDrv }: someDrv
diff --git a/pkgs/test/nixpkgs-check-by-name/tests/package-variants/pkgs/by-name/fo/foo/package.nix b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/pkgs/by-name/fo/foo/package.nix
new file mode 100644
index 0000000000000..a1b92efbbadb9
--- /dev/null
+++ b/pkgs/test/nixpkgs-check-by-name/tests/package-variants/pkgs/by-name/fo/foo/package.nix
@@ -0,0 +1 @@
+{ someDrv }: someDrv