···385 recurseIntoAttrs
386 removeSuffix
387 ;
388- inherit (lib.path) append;
389390 # Generate an attrset corresponding to a given directory.
391 # This function is outside `packagesFromDirectoryRecursive`'s lambda expression,
···396 name: type:
397 # for each directory entry
398 let
399- path = append directory name;
400 in
401 if type == "directory" then
402 {
···429 directory,
430 }@args:
431 let
432- defaultPath = append directory "package.nix";
433 in
434 if pathExists defaultPath then
435 # if `${directory}/package.nix` exists, call it directly
···385 recurseIntoAttrs
386 removeSuffix
387 ;
0388389 # Generate an attrset corresponding to a given directory.
390 # This function is outside `packagesFromDirectoryRecursive`'s lambda expression,
···395 name: type:
396 # for each directory entry
397 let
398+ path = directory + "/${name}";
399 in
400 if type == "directory" then
401 {
···428 directory,
429 }@args:
430 let
431+ defaultPath = directory + "/package.nix";
432 in
433 if pathExists defaultPath then
434 # if `${directory}/package.nix` exists, call it directly
+28
lib/tests/misc.nix
···4158 };
4159 };
416000000000000000000000000000004161 # Check that `packagesFromDirectoryRecursive` can process a directory with a
4162 # top-level `package.nix` file into a single package.
4163 testPackagesFromDirectoryRecursiveTopLevelPackageNix = {
···4158 };
4159 };
41604161+ # Make sure that passing a string for the `directory` works.
4162+ #
4163+ # See: https://github.com/NixOS/nixpkgs/pull/361424#discussion_r1934813568
4164+ # See: https://github.com/NixOS/nix/issues/9428
4165+ testPackagesFromDirectoryRecursiveStringDirectory = {
4166+ expr = packagesFromDirectoryRecursive {
4167+ callPackage = path: overrides: import path overrides;
4168+ # Do NOT remove the `builtins.toString` call here!!!
4169+ directory = builtins.toString ./packages-from-directory/plain;
4170+ };
4171+ expected = {
4172+ a = "a";
4173+ b = "b";
4174+ # Note: Other files/directories in `./test-data/c/` are ignored and can be
4175+ # used by `package.nix`.
4176+ c = "c";
4177+ my-namespace = {
4178+ d = "d";
4179+ e = "e";
4180+ f = "f";
4181+ my-sub-namespace = {
4182+ g = "g";
4183+ h = "h";
4184+ };
4185+ };
4186+ };
4187+ };
4188+4189 # Check that `packagesFromDirectoryRecursive` can process a directory with a
4190 # top-level `package.nix` file into a single package.
4191 testPackagesFromDirectoryRecursiveTopLevelPackageNix = {