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,30 +56,10 @@
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 {
# default = watch;
# build = flake-utils.lib.mkApp {
# drv = build-script;
# };
# watch = flake-utils.lib.mkApp {
# drv = watch-script;
# };
# };
#
# devShells.default = typixLib.devShell { # devShells.default = typixLib.devShell {
# inherit (commonArgs) fontPaths virtualPaths; # inherit (commonArgs) fontPaths virtualPaths;
# packages = [ # packages = [

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))
)