···18 ;
1920 inherit (lib.filesystem)
21- pathIsDirectory
22- pathIsRegularFile
23 pathType
24- packagesFromDirectoryRecursive
25 ;
2627 inherit (lib.strings)
···363 directory,
364 ...
365 }:
366- assert pathIsDirectory directory;
367 let
368- inherit (lib.path) append;
369- defaultPath = append directory "package.nix";
0000000000000000000000000000000000000000000370 in
371- if pathIsRegularFile defaultPath then
372- # if `${directory}/package.nix` exists, call it directly
373- callPackage defaultPath {}
374- else lib.concatMapAttrs (name: type:
375- # otherwise, for each directory entry
376- let path = append directory name; in
377- if type == "directory" then {
378- # recurse into directories
379- "${name}" = packagesFromDirectoryRecursive {
380- inherit callPackage;
381- directory = path;
382- };
383- } else if type == "regular" && hasSuffix ".nix" name then {
384- # call .nix files
385- "${lib.removeSuffix ".nix" name}" = callPackage path {};
386- } else if type == "regular" then {
387- # ignore non-nix files
388- } else throw ''
389- lib.filesystem.packagesFromDirectoryRecursive: Unsupported file type ${type} at path ${toString path}
390- ''
391- ) (builtins.readDir directory);
392}
···18 ;
1920 inherit (lib.filesystem)
0021 pathType
022 ;
2324 inherit (lib.strings)
···360 directory,
361 ...
362 }:
0363 let
364+ # Determine if a directory entry from `readDir` indicates a package or
365+ # directory of packages.
366+ directoryEntryIsPackage = basename: type:
367+ type == "directory" || hasSuffix ".nix" basename;
368+369+ # List directory entries that indicate packages in the given `path`.
370+ packageDirectoryEntries = path:
371+ filterAttrs directoryEntryIsPackage (readDir path);
372+373+ # Transform a directory entry (a `basename` and `type` pair) into a
374+ # package.
375+ directoryEntryToAttrPair = subdirectory: basename: type:
376+ let
377+ path = subdirectory + "/${basename}";
378+ in
379+ if type == "regular"
380+ then
381+ {
382+ name = removeSuffix ".nix" basename;
383+ value = callPackage path { };
384+ }
385+ else
386+ if type == "directory"
387+ then
388+ {
389+ name = basename;
390+ value = packagesFromDirectory path;
391+ }
392+ else
393+ throw
394+ ''
395+ lib.filesystem.packagesFromDirectoryRecursive: Unsupported file type ${type} at path ${toString subdirectory}
396+ '';
397+398+ # Transform a directory into a package (if there's a `package.nix`) or
399+ # set of packages (otherwise).
400+ packagesFromDirectory = path:
401+ let
402+ defaultPackagePath = path + "/package.nix";
403+ in
404+ if pathExists defaultPackagePath
405+ then callPackage defaultPackagePath { }
406+ else mapAttrs'
407+ (directoryEntryToAttrPair path)
408+ (packageDirectoryEntries path);
409 in
410+ packagesFromDirectory directory;
00000000000000000000411}
+1-1
pkgs/by-name/da/dashy-ui/package.nix
···30 # the way the client parses things
31 # - Instead, we use `yq-go` to convert it to yaml
32 # Config validation needs to happen after yarnConfigHook, since it's what sets the yarn offline cache
33- postYarnConfigHook = lib.optional (settings != { }) ''
34 echo "Writing settings override..."
35 yq --output-format yml '${builtins.toFile "conf.json" ''${builtins.toJSON settings}''}' > user-data/conf.yml
36 yarn validate-config --offline
···30 # the way the client parses things
31 # - Instead, we use `yq-go` to convert it to yaml
32 # Config validation needs to happen after yarnConfigHook, since it's what sets the yarn offline cache
33+ preBuild = lib.optional (settings != { }) ''
34 echo "Writing settings override..."
35 yq --output-format yml '${builtins.toFile "conf.json" ''${builtins.toJSON settings}''}' > user-data/conf.yml
36 yarn validate-config --offline