feat: add by-course nested package hierarchy system

This commit is contained in:
Youwen Wu 2024-10-20 02:02:14 -07:00
parent c6f1cdeb0f
commit 68ed4f2261
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
3 changed files with 13 additions and 41 deletions

View file

@ -56,41 +56,21 @@
in
{
# checks = {
# inherit build-drv build-script watch-script;
# };
# legacyPackages = {
# phil-1 = {
# paper-1 = alexandriaLib.callTypstProject (import ./documents/by-course/phil-1/paper-1/package.nix);
# };
# digression-linear-algebra = alexandriaLib.callTypstProject (import ./documents/by-name/digression-linear-algebra/package.nix);
# };
legacyPackages = (
(alexandriaLib.indexByName ./documents/by-name)
// (alexandriaLib.indexByCourse ./documents/by-course)
);
# apps = rec {
# default = watch;
# build = flake-utils.lib.mkApp {
# drv = build-script;
# };
# watch = flake-utils.lib.mkApp {
# drv = watch-script;
# };
# };
#
# devShells.default = typixLib.devShell {
# inherit (commonArgs) fontPaths virtualPaths;
# packages = [
# # WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
# # See https://github.com/loqusion/typix/issues/2
# # build-script
# watch-script
# # More packages can be added here, like typstfmt
# pkgs.typstyle
# ];
# };
# devShells.default = typixLib.devShell {
# inherit (commonArgs) fontPaths virtualPaths;
# packages = [
# # WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
# # See https://github.com/loqusion/typix/issues/2
# # build-script
# watch-script
# # More packages can be added here, like typstfmt
# pkgs.typstyle
# ];
# };
}
);
}

View file

@ -17,7 +17,5 @@ rec {
}
);
indexByName = (import ./indexByName.nix) (defaultArgs // { inherit callTypstProject; });
indexByCourse = (import ./indexByCourse.nix) (
defaultArgs // { inherit callTypstProject indexByName; }
);
indexByCourse = (import ./indexByCourse.nix) (defaultArgs // { inherit indexByName; });
}

View file

@ -1,6 +1,5 @@
{
pkgs,
callTypstProject,
indexByName,
...
}:
@ -28,15 +27,10 @@ let
# Additionally in either of those alternatives, we would have to duplicate the hardcoding of "README.md"
{ }
else
# mapAttrs (name: _: baseDirectory + "/${shard}/${name}/package.nix") (
# readDir (baseDirectory + "/${shard}")
# );
mapAttrs (a: b: indexByName (baseDirectory + "/${a}")) (readDir baseDirectory);
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))
)
mergeAttrsList (mapAttrsToList namesForShard (readDir baseDirectory))