···385385 recurseIntoAttrs
386386 removeSuffix
387387 ;
388388- inherit (lib.path) append;
389388390389 # Generate an attrset corresponding to a given directory.
391390 # This function is outside `packagesFromDirectoryRecursive`'s lambda expression,
···396395 name: type:
397396 # for each directory entry
398397 let
399399- path = append directory name;
398398+ path = directory + "/${name}";
400399 in
401400 if type == "directory" then
402401 {
···429428 directory,
430429 }@args:
431430 let
432432- defaultPath = append directory "package.nix";
431431+ defaultPath = directory + "/package.nix";
433432 in
434433 if pathExists defaultPath then
435434 # if `${directory}/package.nix` exists, call it directly
+28
lib/tests/misc.nix
···41584158 };
41594159 };
4160416041614161+ # Make sure that passing a string for the `directory` works.
41624162+ #
41634163+ # See: https://github.com/NixOS/nixpkgs/pull/361424#discussion_r1934813568
41644164+ # See: https://github.com/NixOS/nix/issues/9428
41654165+ testPackagesFromDirectoryRecursiveStringDirectory = {
41664166+ expr = packagesFromDirectoryRecursive {
41674167+ callPackage = path: overrides: import path overrides;
41684168+ # Do NOT remove the `builtins.toString` call here!!!
41694169+ directory = builtins.toString ./packages-from-directory/plain;
41704170+ };
41714171+ expected = {
41724172+ a = "a";
41734173+ b = "b";
41744174+ # Note: Other files/directories in `./test-data/c/` are ignored and can be
41754175+ # used by `package.nix`.
41764176+ c = "c";
41774177+ my-namespace = {
41784178+ d = "d";
41794179+ e = "e";
41804180+ f = "f";
41814181+ my-sub-namespace = {
41824182+ g = "g";
41834183+ h = "h";
41844184+ };
41854185+ };
41864186+ };
41874187+ };
41884188+41614189 # Check that `packagesFromDirectoryRecursive` can process a directory with a
41624190 # top-level `package.nix` file into a single package.
41634191 testPackagesFromDirectoryRecursiveTopLevelPackageNix = {