2024-10-20 01:17:48 -07:00
|
|
|
{ pkgs, callTypstProject, ... }:
|
|
|
|
baseDirectory:
|
|
|
|
let
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
inherit (lib.attrsets)
|
|
|
|
mapAttrs
|
|
|
|
mapAttrsToList
|
|
|
|
mergeAttrsList
|
|
|
|
;
|
|
|
|
inherit (builtins) readDir;
|
|
|
|
in
|
|
|
|
let
|
|
|
|
# Package files for a single shard
|
|
|
|
# Type: String -> String -> AttrsOf Path
|
|
|
|
namesForShard =
|
2024-10-20 01:51:46 -07:00
|
|
|
name: type:
|
2024-10-20 01:17:48 -07:00
|
|
|
if type != "directory" then
|
|
|
|
# Ignore all non-directories. Technically only README.md is allowed as a file in the base directory, so we could alternatively:
|
|
|
|
# - Assume that README.md is the only file and change the condition to `shard == "README.md"` for a minor performance improvement.
|
|
|
|
# This would however cause very poor error messages if there's other files.
|
|
|
|
# - Ensure that README.md is the only file, throwing a better error message if that's not the case.
|
|
|
|
# However this would make for a poor code architecture, because one type of error would have to be duplicated in the validity checks and here.
|
|
|
|
# Additionally in either of those alternatives, we would have to duplicate the hardcoding of "README.md"
|
|
|
|
{ }
|
|
|
|
else
|
2024-10-20 01:51:46 -07:00
|
|
|
# mapAttrs (name: _: baseDirectory + "/${shard}/${name}/package.nix") (
|
|
|
|
# readDir (baseDirectory + "/${shard}")
|
|
|
|
# );
|
|
|
|
mapAttrs (name: _: baseDirectory + "/${name}/package.nix") (readDir baseDirectory);
|
2024-10-20 01:17:48 -07:00
|
|
|
|
|
|
|
in
|
|
|
|
# mapAttrs (a: b: builtins.trace (builtins.tryEval a) b) (
|
|
|
|
# mergeAttrsList (mapAttrsToList namesForShard (readDir baseDirectory))
|
|
|
|
# )
|
|
|
|
mapAttrs (a: b: callTypstProject (import (/. + b))) (
|
|
|
|
mergeAttrsList (mapAttrsToList namesForShard (readDir baseDirectory))
|
|
|
|
)
|