diff options
author | Silvan Mosberger <contact@infinisil.com> | 2023-12-19 22:03:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 22:03:01 +0100 |
commit | cf47b9a5c0bd33901014cee1178d206646997711 (patch) | |
tree | b3fbfafd4d43a3df8c7200105d5b5e4f7e88d916 /lib/tests | |
parent | bfd600c3fa9350d90804126cb6b22db6ccc752d1 (diff) | |
parent | 090b929b8ab9b7df11825554828f0cb51e9eab9b (diff) |
Merge pull request #270537 from 9999years/packagesFromDirectory
lib.packagesFromDirectoryRecursive: init
Diffstat (limited to 'lib/tests')
12 files changed, 49 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 2884e880e13aa..cf7fa9f2e2849 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -2055,4 +2055,37 @@ runTests { expr = meta.platformMatch { } "x86_64-linux"; expected = false; }; + + testPackagesFromDirectoryRecursive = { + expr = packagesFromDirectoryRecursive { + callPackage = path: overrides: import path overrides; + directory = ./packages-from-directory; + }; + expected = { + a = "a"; + b = "b"; + # Note: Other files/directories in `./test-data/c/` are ignored and can be + # used by `package.nix`. + c = "c"; + my-namespace = { + d = "d"; + e = "e"; + f = "f"; + my-sub-namespace = { + g = "g"; + h = "h"; + }; + }; + }; + }; + + # Check that `packagesFromDirectoryRecursive` can process a directory with a + # top-level `package.nix` file into a single package. + testPackagesFromDirectoryRecursiveTopLevelPackageNix = { + expr = packagesFromDirectoryRecursive { + callPackage = path: overrides: import path overrides; + directory = ./packages-from-directory/c; + }; + expected = "c"; + }; } diff --git a/lib/tests/packages-from-directory/a.nix b/lib/tests/packages-from-directory/a.nix new file mode 100644 index 0000000000000..54f9eafd8e878 --- /dev/null +++ b/lib/tests/packages-from-directory/a.nix @@ -0,0 +1,2 @@ +{ }: +"a" diff --git a/lib/tests/packages-from-directory/b.nix b/lib/tests/packages-from-directory/b.nix new file mode 100644 index 0000000000000..345b3c25fa2a9 --- /dev/null +++ b/lib/tests/packages-from-directory/b.nix @@ -0,0 +1,2 @@ +{ }: +"b" diff --git a/lib/tests/packages-from-directory/c/my-extra-feature.patch b/lib/tests/packages-from-directory/c/my-extra-feature.patch new file mode 100644 index 0000000000000..e69de29bb2d1d --- /dev/null +++ b/lib/tests/packages-from-directory/c/my-extra-feature.patch diff --git a/lib/tests/packages-from-directory/c/not-a-namespace/not-a-package.nix b/lib/tests/packages-from-directory/c/not-a-namespace/not-a-package.nix new file mode 100644 index 0000000000000..e69de29bb2d1d --- /dev/null +++ b/lib/tests/packages-from-directory/c/not-a-namespace/not-a-package.nix diff --git a/lib/tests/packages-from-directory/c/package.nix b/lib/tests/packages-from-directory/c/package.nix new file mode 100644 index 0000000000000..c1203cdde9602 --- /dev/null +++ b/lib/tests/packages-from-directory/c/package.nix @@ -0,0 +1,2 @@ +{ }: +"c" diff --git a/lib/tests/packages-from-directory/c/support-definitions.nix b/lib/tests/packages-from-directory/c/support-definitions.nix new file mode 100644 index 0000000000000..e69de29bb2d1d --- /dev/null +++ b/lib/tests/packages-from-directory/c/support-definitions.nix diff --git a/lib/tests/packages-from-directory/my-namespace/d.nix b/lib/tests/packages-from-directory/my-namespace/d.nix new file mode 100644 index 0000000000000..6e5eaa09e9956 --- /dev/null +++ b/lib/tests/packages-from-directory/my-namespace/d.nix @@ -0,0 +1,2 @@ +{ }: +"d" diff --git a/lib/tests/packages-from-directory/my-namespace/e.nix b/lib/tests/packages-from-directory/my-namespace/e.nix new file mode 100644 index 0000000000000..50bd742f800cb --- /dev/null +++ b/lib/tests/packages-from-directory/my-namespace/e.nix @@ -0,0 +1,2 @@ +{ }: +"e" diff --git a/lib/tests/packages-from-directory/my-namespace/f/package.nix b/lib/tests/packages-from-directory/my-namespace/f/package.nix new file mode 100644 index 0000000000000..c9a66c2eb1208 --- /dev/null +++ b/lib/tests/packages-from-directory/my-namespace/f/package.nix @@ -0,0 +1,2 @@ +{ }: +"f" diff --git a/lib/tests/packages-from-directory/my-namespace/my-sub-namespace/g.nix b/lib/tests/packages-from-directory/my-namespace/my-sub-namespace/g.nix new file mode 100644 index 0000000000000..4ecaffbf1dc73 --- /dev/null +++ b/lib/tests/packages-from-directory/my-namespace/my-sub-namespace/g.nix @@ -0,0 +1,2 @@ +{ }: +"g" diff --git a/lib/tests/packages-from-directory/my-namespace/my-sub-namespace/h.nix b/lib/tests/packages-from-directory/my-namespace/my-sub-namespace/h.nix new file mode 100644 index 0000000000000..3756275ba7524 --- /dev/null +++ b/lib/tests/packages-from-directory/my-namespace/my-sub-namespace/h.nix @@ -0,0 +1,2 @@ +{ }: +"h" |