From 68ed4f226196eb197b8456a35d87a71948b7aa41 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sun, 20 Oct 2024 02:02:14 -0700 Subject: [PATCH] feat: add by-course nested package hierarchy system --- 2024/flake.nix | 42 +++++++++------------------------- 2024/nix/lib/default.nix | 4 +--- 2024/nix/lib/indexByCourse.nix | 8 +------ 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/2024/flake.nix b/2024/flake.nix index 37ca20b..361bd41 100644 --- a/2024/flake.nix +++ b/2024/flake.nix @@ -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 + # ]; + # }; } ); } diff --git a/2024/nix/lib/default.nix b/2024/nix/lib/default.nix index cbbe898..0724cd3 100644 --- a/2024/nix/lib/default.nix +++ b/2024/nix/lib/default.nix @@ -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; }); } diff --git a/2024/nix/lib/indexByCourse.nix b/2024/nix/lib/indexByCourse.nix index 48541c7..16e0b0b 100644 --- a/2024/nix/lib/indexByCourse.nix +++ b/2024/nix/lib/indexByCourse.nix @@ -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))