Loading lib/filesystem.nix +2 −3 Original line number Diff line number Diff line Loading @@ -385,7 +385,6 @@ in recurseIntoAttrs removeSuffix ; inherit (lib.path) append; # Generate an attrset corresponding to a given directory. # This function is outside `packagesFromDirectoryRecursive`'s lambda expression, Loading @@ -396,7 +395,7 @@ in name: type: # for each directory entry let path = append directory name; path = directory + "/${name}"; in if type == "directory" then { Loading Loading @@ -429,7 +428,7 @@ in directory, }@args: let defaultPath = append directory "package.nix"; defaultPath = directory + "/package.nix"; in if pathExists defaultPath then # if `${directory}/package.nix` exists, call it directly Loading lib/tests/misc.nix +28 −0 Original line number Diff line number Diff line Loading @@ -4158,6 +4158,34 @@ runTests { }; }; # Make sure that passing a string for the `directory` works. # # See: https://github.com/NixOS/nixpkgs/pull/361424#discussion_r1934813568 # See: https://github.com/NixOS/nix/issues/9428 testPackagesFromDirectoryRecursiveStringDirectory = { expr = packagesFromDirectoryRecursive { callPackage = path: overrides: import path overrides; # Do NOT remove the `builtins.toString` call here!!! directory = builtins.toString ./packages-from-directory/plain; }; 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 = { Loading Loading
lib/filesystem.nix +2 −3 Original line number Diff line number Diff line Loading @@ -385,7 +385,6 @@ in recurseIntoAttrs removeSuffix ; inherit (lib.path) append; # Generate an attrset corresponding to a given directory. # This function is outside `packagesFromDirectoryRecursive`'s lambda expression, Loading @@ -396,7 +395,7 @@ in name: type: # for each directory entry let path = append directory name; path = directory + "/${name}"; in if type == "directory" then { Loading Loading @@ -429,7 +428,7 @@ in directory, }@args: let defaultPath = append directory "package.nix"; defaultPath = directory + "/package.nix"; in if pathExists defaultPath then # if `${directory}/package.nix` exists, call it directly Loading
lib/tests/misc.nix +28 −0 Original line number Diff line number Diff line Loading @@ -4158,6 +4158,34 @@ runTests { }; }; # Make sure that passing a string for the `directory` works. # # See: https://github.com/NixOS/nixpkgs/pull/361424#discussion_r1934813568 # See: https://github.com/NixOS/nix/issues/9428 testPackagesFromDirectoryRecursiveStringDirectory = { expr = packagesFromDirectoryRecursive { callPackage = path: overrides: import path overrides; # Do NOT remove the `builtins.toString` call here!!! directory = builtins.toString ./packages-from-directory/plain; }; 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 = { Loading