diff --git a/.gitignore b/.gitignore index 8dbf129..0627f5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ -lib.typ +# lib.typ +lib/ +src/lib/ config/universities.yaml *.pdf # nix artifacts result +result-* diff --git a/appendices.typ b/appendices.typ deleted file mode 100644 index 31ff0b5..0000000 --- a/appendices.typ +++ /dev/null @@ -1,4 +0,0 @@ -#import "utils.typ": code - -= Код програми sample.c -#code(read("assets/sample.c")) diff --git a/flake.lock b/flake.lock index 5ceee70..7027761 100644 --- a/flake.lock +++ b/flake.lock @@ -21,8 +21,8 @@ "local-nure": { "flake": false, "locked": { - "lastModified": 1768300920, - "narHash": "sha256-Ndy2YhxHFyMCy0B5oT+nRlA3T8S16u1AzPCKlK9UJ4I=", + "lastModified": 1769126611, + "narHash": "sha256-4qmXN7kx87pEpZHFJpyRbLfZ5GanF5Jbi1Bmfx6ZXss=", "path": "/storage/git/typst_nure_template", "type": "path" }, @@ -31,6 +31,22 @@ "type": "path" } }, + "local-nure-upstream": { + "flake": false, + "locked": { + "lastModified": 1768301144, + "narHash": "sha256-VHZXALfaAw5f32mClZTS7MeTSaDSQtErAjI+lgpYIZk=", + "ref": "refs/heads/0.1.0", + "rev": "549d7f060f81a6356c43b2c231e6453ddae19fca", + "revCount": 111, + "type": "git", + "url": "ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template" + }, + "original": { + "type": "git", + "url": "ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template" + } + }, "nixpkgs": { "locked": { "lastModified": 1763421233, @@ -51,6 +67,7 @@ "inputs": { "flake-utils": "flake-utils", "local-nure": "local-nure", + "local-nure-upstream": "local-nure-upstream", "nixpkgs": "nixpkgs", "typix": "typix" } @@ -77,11 +94,11 @@ ] }, "locked": { - "lastModified": 1762505280, - "narHash": "sha256-9/DYuuh14LCQDpWZceY2GF3UvUX2PCrH9eqryBULOqk=", + "lastModified": 1769071922, + "narHash": "sha256-WD8cMrUlqWJWDAD8+B6MUyEuWvi/fgGgv5Wg0xF/Zkc=", "owner": "loqusion", "repo": "typix", - "rev": "489712e2665e1991d17e574b2a69662011cb9113", + "rev": "5d334996b24af342b0992f7f432fcb301ed67314", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 61959c7..9f76fb3 100644 --- a/flake.nix +++ b/flake.nix @@ -9,9 +9,11 @@ flake-utils.url = "github:numtide/flake-utils"; - local-nure.url = "git+ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template"; # local-nure.url = "git+ssh://gitea@gitea.linerds.us/unexplrd/typst_nure_template"; - # local-nure.url = "path:/storage/git/typst_nure_template"; + local-nure-upstream.url = "git+ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template"; + local-nure-upstream.flake = false; + + local-nure.url = "path:/storage/git/typst_nure_template"; local-nure.flake = false; # Example of downloading icons from a non-flake source @@ -30,23 +32,26 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; inherit (pkgs) lib; - # inherit (lib.strings) escapeShellArg; + inherit (lib.strings) escapeShellArg; typixLib = typix.lib.${system}; src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ - (lib.fileset.fromSource (typixLib.cleanTypstSource ./.)) - (lib.fileset.maybeMissing ./assets) - (lib.fileset.maybeMissing ./chapters) - (lib.fileset.maybeMissing ./doc.toml) - (lib.fileset.maybeMissing ./figures) - (lib.fileset.maybeMissing ./utils.typ) + # lib/ gets imported, which is unwanted + # (lib.fileset.fromSource (typixLib.cleanTypstSource ./.)) + # ./main.typ + # (lib.fileset.maybeMissing ./doc.toml) + # (lib.fileset.maybeMissing ./utils.typ) + # (lib.fileset.maybeMissing ./chapters) + # (lib.fileset.maybeMissing ./assets) + # (lib.fileset.maybeMissing ./figures) + ./src ]; }; commonArgs = { - typstSource = "main.typ"; + typstSource = "src/main.typ"; fontPaths = [ "${pkgs.liberation_ttf}/share/fonts/truetype" @@ -58,42 +63,48 @@ virtualPaths = [ # Add paths that must be locally accessible to typst here - { - dest = "lib.typ"; - src = "${inputs.local-nure}/lib.typ"; - } - { - dest = "config/universities.yaml"; - src = "${inputs.local-nure}/config/universities.yaml"; - } + # { + # dest = "src/lib"; + # src = "${inputs.local-nure}/src"; + # } + # { + # dest = "config/universities.yaml"; + # src = "${inputs.local-nure}/src/config/universities.yaml"; + # } ]; }; - # mkTypstPackagesDrv = name: entries: let - # linkFarmEntries = - # lib.foldl (set: { - # name, - # version, - # namespace, - # input, - # }: - # set - # // { - # "${namespace}/${name}/${version}" = input; - # }) - # {} - # entries; - # in - # pkgs.linkFarm name linkFarmEntries; + mkTypstPackagesDrv = name: entries: let + linkFarmEntries = + lib.foldl (set: { + name, + version, + namespace, + input, + }: + set + // { + "${namespace}/${name}/${version}" = input; + }) + {} + entries; + in + pkgs.linkFarm name linkFarmEntries; - # unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [ - # { - # name = "nure"; - # version = "0.1.0"; - # namespace = "local"; - # input = inputs.local-nure; - # } - # ]; + unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [ + { + name = "test-multifile"; + version = "0.1.0"; + namespace = "unexplrd"; + input = inputs.local-nure; + } + { + name = "nure"; + version = "0.1.0"; + namespace = "local"; + input = inputs.local-nure-upstream; + } + ]; # Any transitive dependencies must be added here # See https://loqusion.github.io/typix/recipes/using-typst-packages.html#the-typstpackages-attribute @@ -111,7 +122,7 @@ // { inherit src; # inherit unstable_typstPackages; - # TYPST_PACKAGE_PATH = unpublishedTypstPackages; + TYPST_PACKAGE_PATH = unpublishedTypstPackages; }); # Compile a Typst project, and then copy the result @@ -120,18 +131,19 @@ // { inherit src; # inherit unstable_typstPackages; - # TYPST_PACKAGE_PATH = unpublishedTypstPackages; + TYPST_PACKAGE_PATH = unpublishedTypstPackages; }); # Watch a project and recompile on changes - watch-script = typixLib.watchTypstProject (commonArgs - // { - # typstWatchCommand = "TYPST_PACKAGE_PATH=${escapeShellArg unpublishedTypstPackages} typst watch"; + watch-script = typixLib.watchTypstProject (lib.recursiveUpdate commonArgs + { + typstWatchCommand = "TYPST_PACKAGE_PATH=${escapeShellArg unpublishedTypstPackages} typst watch"; }); in { checks = {inherit build-drv build-script watch-script;}; packages.default = build-drv; + packages.watch = watch-script; apps = rec { default = watch; @@ -145,19 +157,20 @@ 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 - ] - ++ (with pkgs; [ - # More packages can be added here, like typstfmt - just - typstfmt - yq - ]); + + env = { + TYPST_PACKAGE_PATH = escapeShellArg unpublishedTypstPackages; + }; + packages = with pkgs; [ + # WARNING: Don't run `typst-build` directly, instead use `nix run .#build` + # See https://github.com/loqusion/typix/issues/2 + # build-script + watch-script + + just + typstyle + yq + ]; }; }); } diff --git a/justfile b/justfile index 0abb570..f2665d3 100644 --- a/justfile +++ b/justfile @@ -3,9 +3,9 @@ alias c := compile alias nw := nix-watch alias nb := nix-build -alias ns := nix-shell +alias nd := nix-develop -file := "main.typ" +file := "src/main.typ" out := `cat doc.toml | tomlq '.doctype + (.worknumber | tostring) + "_" + (.authors[0].name | split(" ")[0]) + "_" + (.authors[0].edu + "-" + .authors[0].group) + "_" + .subject + ".pdf"'` [group('typst')] @@ -19,8 +19,8 @@ copy-done: cp main.pdf ../{{out}} [group('nix')] -nix-shell: - nix shell nixpkgs#{yq,typst} +nix-develop: + nix develop . [group('nix')] nix-watch: nix run .#watch diff --git a/assets/sample.c b/src/assets/sample.c similarity index 100% rename from assets/sample.c rename to src/assets/sample.c diff --git a/assets/table.csv b/src/assets/table.csv similarity index 100% rename from assets/table.csv rename to src/assets/table.csv diff --git a/chapters/1.typ b/src/chapters/1.typ similarity index 100% rename from chapters/1.typ rename to src/chapters/1.typ diff --git a/src/chapters/appendices.typ b/src/chapters/appendices.typ new file mode 100644 index 0000000..b221b49 --- /dev/null +++ b/src/chapters/appendices.typ @@ -0,0 +1,4 @@ +#import "/utils.typ": code + += Код програми sample.c +#code(read("/assets/sample.c")) diff --git a/doc.toml b/src/doc.toml similarity index 94% rename from doc.toml rename to src/doc.toml index b4bdbce..784502b 100644 --- a/doc.toml +++ b/src/doc.toml @@ -16,7 +16,7 @@ gender = "m" [[authors]] name = "Косач Л. П." -edu_program = "ПЗПІ" +edu_program = "КУІБ" group = "23-2" gender = "f" variant = 8 diff --git a/figures/Google-Logo-700x394.png b/src/figures/Google-Logo-700x394.png similarity index 100% rename from figures/Google-Logo-700x394.png rename to src/figures/Google-Logo-700x394.png diff --git a/main.typ b/src/main.typ similarity index 66% rename from main.typ rename to src/main.typ index 081847b..746b541 100644 --- a/main.typ +++ b/src/main.typ @@ -1,11 +1,14 @@ -#import "/lib.typ": * -#import "/utils.typ": * +#import "@unexplrd/test-multifile:0.1.0": * +// #import "/lib/lib.typ": * +#import "utils.typ": * + +#import style: spacing // #show: correctly-indent-list-and-enum-items -// #show: dstu-style // Для рефератів, нестандартних робіт, тощо +// #show: style.dstu #show: pz-lb.with( - ..toml("/doc.toml"), + ..toml("doc.toml"), title: lorem(2), ) @@ -28,7 +31,7 @@ $ 1/2 dot 3 = 3/2 $ #lorem(20) -#img("figures/Google-Logo-700x394.png", [Корпорація зла], width: 60%) +// #img("/figures/Google-Logo-700x394.png", [Корпорація зла], width: 60%) #lorem(50) @@ -48,4 +51,4 @@ $ 1/2 dot 3 = 3/2 $ #lorem(20) -#appendices-style(include "appendices.typ") +#style.appendices(include "chapters/appendices.typ") diff --git a/utils.typ b/src/utils.typ similarity index 97% rename from utils.typ rename to src/utils.typ index 7aaf3c7..7e1ba9b 100644 --- a/utils.typ +++ b/src/utils.typ @@ -1,6 +1,9 @@ /// takes in a string of code, e.g. #code(read("foo.c")) #let code(content) = raw(block: true, theme: none, content) +/// read file as bytes +#let p(path) = bytes(read(path, encoding: none)) + /// include chapters by file names from /chapters #let chapters(ch) = ( array(ch).map(chapter => include str(chapter) + ".typ").join()