Compare commits
4 commits
5dd0370eed
...
68ed4f2261
Author | SHA1 | Date | |
---|---|---|---|
68ed4f2261 | |||
c6f1cdeb0f | |||
588a1dc5a9 | |||
bef1d9f5c0 |
6 changed files with 90 additions and 31 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
result
|
|
@ -56,26 +56,10 @@
|
|||
|
||||
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);
|
||||
};
|
||||
# apps = rec {
|
||||
# default = watch;
|
||||
# build = flake-utils.lib.mkApp {
|
||||
# drv = build-script;
|
||||
# };
|
||||
# watch = flake-utils.lib.mkApp {
|
||||
# drv = watch-script;
|
||||
# };
|
||||
# };
|
||||
#
|
||||
legacyPackages = (
|
||||
(alexandriaLib.indexByName ./documents/by-name)
|
||||
// (alexandriaLib.indexByCourse ./documents/by-course)
|
||||
);
|
||||
# devShells.default = typixLib.devShell {
|
||||
# inherit (commonArgs) fontPaths virtualPaths;
|
||||
# packages = [
|
||||
|
|
|
@ -16,4 +16,6 @@ rec {
|
|||
inherit cleanTypstSource;
|
||||
}
|
||||
);
|
||||
indexByName = (import ./indexByName.nix) (defaultArgs // { inherit callTypstProject; });
|
||||
indexByCourse = (import ./indexByCourse.nix) (defaultArgs // { inherit indexByName; });
|
||||
}
|
||||
|
|
36
2024/nix/lib/indexByCourse.nix
Normal file
36
2024/nix/lib/indexByCourse.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
pkgs,
|
||||
indexByName,
|
||||
...
|
||||
}:
|
||||
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 =
|
||||
shard: type:
|
||||
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
|
||||
mapAttrs (a: b: indexByName (baseDirectory + "/${a}")) (readDir baseDirectory);
|
||||
|
||||
in
|
||||
# mapAttrs (a: b: builtins.trace (builtins.tryEval a) b) (
|
||||
# mergeAttrsList (mapAttrsToList namesForShard (readDir baseDirectory))
|
||||
# )
|
||||
mergeAttrsList (mapAttrsToList namesForShard (readDir baseDirectory))
|
37
2024/nix/lib/indexByName.nix
Normal file
37
2024/nix/lib/indexByName.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ 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 =
|
||||
name: type:
|
||||
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
|
||||
# mapAttrs (name: _: baseDirectory + "/${shard}/${name}/package.nix") (
|
||||
# readDir (baseDirectory + "/${shard}")
|
||||
# );
|
||||
mapAttrs (name: _: baseDirectory + "/${name}/package.nix") (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))
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
/nix/store/fv6y2dqv26lw4gzb2pf6ms5hyikpbkm9-typst
|
Loading…
Reference in a new issue