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 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 = ( legacyPackages = (
(alexandriaLib.indexByName ./documents/by-name) (alexandriaLib.indexByName ./documents/by-name)
// (alexandriaLib.indexByCourse ./documents/by-course) // (alexandriaLib.indexByCourse ./documents/by-course)
); );
# apps = rec { # devShells.default = typixLib.devShell {
# default = watch; # inherit (commonArgs) fontPaths virtualPaths;
# build = flake-utils.lib.mkApp { # packages = [
# drv = build-script; # # WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
# }; # # See https://github.com/loqusion/typix/issues/2
# watch = flake-utils.lib.mkApp { # # build-script
# drv = watch-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; }); indexByName = (import ./indexByName.nix) (defaultArgs // { inherit callTypstProject; });
indexByCourse = (import ./indexByCourse.nix) ( indexByCourse = (import ./indexByCourse.nix) (defaultArgs // { inherit indexByName; });
defaultArgs // { inherit callTypstProject indexByName; }
);
} }

View file

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