reshuffle things

This commit is contained in:
2026-01-23 02:06:39 +02:00
parent b21f4d2281
commit 09f7fdd1d0
13 changed files with 120 additions and 81 deletions

5
.gitignore vendored
View File

@@ -1,7 +1,10 @@
lib.typ # lib.typ
lib/
src/lib/
config/universities.yaml config/universities.yaml
*.pdf *.pdf
# nix artifacts # nix artifacts
result result
result-*

View File

@@ -1,4 +0,0 @@
#import "utils.typ": code
= Код програми sample.c <foo-c>
#code(read("assets/sample.c"))

27
flake.lock generated
View File

@@ -21,8 +21,8 @@
"local-nure": { "local-nure": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1768300920, "lastModified": 1769126611,
"narHash": "sha256-Ndy2YhxHFyMCy0B5oT+nRlA3T8S16u1AzPCKlK9UJ4I=", "narHash": "sha256-4qmXN7kx87pEpZHFJpyRbLfZ5GanF5Jbi1Bmfx6ZXss=",
"path": "/storage/git/typst_nure_template", "path": "/storage/git/typst_nure_template",
"type": "path" "type": "path"
}, },
@@ -31,6 +31,22 @@
"type": "path" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1763421233, "lastModified": 1763421233,
@@ -51,6 +67,7 @@
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"local-nure": "local-nure", "local-nure": "local-nure",
"local-nure-upstream": "local-nure-upstream",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"typix": "typix" "typix": "typix"
} }
@@ -77,11 +94,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1762505280, "lastModified": 1769071922,
"narHash": "sha256-9/DYuuh14LCQDpWZceY2GF3UvUX2PCrH9eqryBULOqk=", "narHash": "sha256-WD8cMrUlqWJWDAD8+B6MUyEuWvi/fgGgv5Wg0xF/Zkc=",
"owner": "loqusion", "owner": "loqusion",
"repo": "typix", "repo": "typix",
"rev": "489712e2665e1991d17e574b2a69662011cb9113", "rev": "5d334996b24af342b0992f7f432fcb301ed67314",
"type": "github" "type": "github"
}, },
"original": { "original": {

133
flake.nix
View File

@@ -9,9 +9,11 @@
flake-utils.url = "github:numtide/flake-utils"; 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 = "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; local-nure.flake = false;
# Example of downloading icons from a non-flake source # Example of downloading icons from a non-flake source
@@ -30,23 +32,26 @@
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib; inherit (pkgs) lib;
# inherit (lib.strings) escapeShellArg; inherit (lib.strings) escapeShellArg;
typixLib = typix.lib.${system}; typixLib = typix.lib.${system};
src = lib.fileset.toSource { src = lib.fileset.toSource {
root = ./.; root = ./.;
fileset = lib.fileset.unions [ fileset = lib.fileset.unions [
(lib.fileset.fromSource (typixLib.cleanTypstSource ./.)) # lib/ gets imported, which is unwanted
(lib.fileset.maybeMissing ./assets) # (lib.fileset.fromSource (typixLib.cleanTypstSource ./.))
(lib.fileset.maybeMissing ./chapters) # ./main.typ
(lib.fileset.maybeMissing ./doc.toml) # (lib.fileset.maybeMissing ./doc.toml)
(lib.fileset.maybeMissing ./figures) # (lib.fileset.maybeMissing ./utils.typ)
(lib.fileset.maybeMissing ./utils.typ) # (lib.fileset.maybeMissing ./chapters)
# (lib.fileset.maybeMissing ./assets)
# (lib.fileset.maybeMissing ./figures)
./src
]; ];
}; };
commonArgs = { commonArgs = {
typstSource = "main.typ"; typstSource = "src/main.typ";
fontPaths = [ fontPaths = [
"${pkgs.liberation_ttf}/share/fonts/truetype" "${pkgs.liberation_ttf}/share/fonts/truetype"
@@ -58,42 +63,48 @@
virtualPaths = [ virtualPaths = [
# Add paths that must be locally accessible to typst here # Add paths that must be locally accessible to typst here
{ # {
dest = "lib.typ"; # dest = "src/lib";
src = "${inputs.local-nure}/lib.typ"; # src = "${inputs.local-nure}/src";
} # }
{ # {
dest = "config/universities.yaml"; # dest = "config/universities.yaml";
src = "${inputs.local-nure}/config/universities.yaml"; # src = "${inputs.local-nure}/src/config/universities.yaml";
} # }
]; ];
}; };
# mkTypstPackagesDrv = name: entries: let mkTypstPackagesDrv = name: entries: let
# linkFarmEntries = linkFarmEntries =
# lib.foldl (set: { lib.foldl (set: {
# name, name,
# version, version,
# namespace, namespace,
# input, input,
# }: }:
# set set
# // { // {
# "${namespace}/${name}/${version}" = input; "${namespace}/${name}/${version}" = input;
# }) })
# {} {}
# entries; entries;
# in in
# pkgs.linkFarm name linkFarmEntries; pkgs.linkFarm name linkFarmEntries;
# unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [ unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [
# { {
# name = "nure"; name = "test-multifile";
# version = "0.1.0"; version = "0.1.0";
# namespace = "local"; namespace = "unexplrd";
# input = inputs.local-nure; input = inputs.local-nure;
# } }
# ]; {
name = "nure";
version = "0.1.0";
namespace = "local";
input = inputs.local-nure-upstream;
}
];
# Any transitive dependencies must be added here # Any transitive dependencies must be added here
# See https://loqusion.github.io/typix/recipes/using-typst-packages.html#the-typstpackages-attribute # See https://loqusion.github.io/typix/recipes/using-typst-packages.html#the-typstpackages-attribute
@@ -111,7 +122,7 @@
// { // {
inherit src; inherit src;
# inherit unstable_typstPackages; # inherit unstable_typstPackages;
# TYPST_PACKAGE_PATH = unpublishedTypstPackages; TYPST_PACKAGE_PATH = unpublishedTypstPackages;
}); });
# Compile a Typst project, and then copy the result # Compile a Typst project, and then copy the result
@@ -120,18 +131,19 @@
// { // {
inherit src; inherit src;
# inherit unstable_typstPackages; # inherit unstable_typstPackages;
# TYPST_PACKAGE_PATH = unpublishedTypstPackages; TYPST_PACKAGE_PATH = unpublishedTypstPackages;
}); });
# Watch a project and recompile on changes # Watch a project and recompile on changes
watch-script = typixLib.watchTypstProject (commonArgs watch-script = typixLib.watchTypstProject (lib.recursiveUpdate commonArgs
// { {
# typstWatchCommand = "TYPST_PACKAGE_PATH=${escapeShellArg unpublishedTypstPackages} typst watch"; typstWatchCommand = "TYPST_PACKAGE_PATH=${escapeShellArg unpublishedTypstPackages} typst watch";
}); });
in { in {
checks = {inherit build-drv build-script watch-script;}; checks = {inherit build-drv build-script watch-script;};
packages.default = build-drv; packages.default = build-drv;
packages.watch = watch-script;
apps = rec { apps = rec {
default = watch; default = watch;
@@ -145,19 +157,20 @@
devShells.default = typixLib.devShell { devShells.default = typixLib.devShell {
inherit (commonArgs) fontPaths virtualPaths; inherit (commonArgs) fontPaths virtualPaths;
packages =
[ env = {
# WARNING: Don't run `typst-build` directly, instead use `nix run .#build` TYPST_PACKAGE_PATH = escapeShellArg unpublishedTypstPackages;
# See https://github.com/loqusion/typix/issues/2 };
# build-script packages = with pkgs; [
watch-script # WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
] # See https://github.com/loqusion/typix/issues/2
++ (with pkgs; [ # build-script
# More packages can be added here, like typstfmt watch-script
just
typstfmt just
yq typstyle
]); yq
];
}; };
}); });
} }

View File

@@ -3,9 +3,9 @@ alias c := compile
alias nw := nix-watch alias nw := nix-watch
alias nb := nix-build 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"'` out := `cat doc.toml | tomlq '.doctype + (.worknumber | tostring) + "_" + (.authors[0].name | split(" ")[0]) + "_" + (.authors[0].edu + "-" + .authors[0].group) + "_" + .subject + ".pdf"'`
[group('typst')] [group('typst')]
@@ -19,8 +19,8 @@ copy-done:
cp main.pdf ../{{out}} cp main.pdf ../{{out}}
[group('nix')] [group('nix')]
nix-shell: nix-develop:
nix shell nixpkgs#{yq,typst} nix develop .
[group('nix')] [group('nix')]
nix-watch: nix-watch:
nix run .#watch nix run .#watch

View File

@@ -0,0 +1,4 @@
#import "/utils.typ": code
= Код програми sample.c <foo-c>
#code(read("/assets/sample.c"))

View File

@@ -16,7 +16,7 @@ gender = "m"
[[authors]] [[authors]]
name = "Косач Л. П." name = "Косач Л. П."
edu_program = "ПЗПІ" edu_program = "КУІБ"
group = "23-2" group = "23-2"
gender = "f" gender = "f"
variant = 8 variant = 8

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,11 +1,14 @@
#import "/lib.typ": * #import "@unexplrd/test-multifile:0.1.0": *
#import "/utils.typ": * // #import "/lib/lib.typ": *
#import "utils.typ": *
#import style: spacing
// #show: correctly-indent-list-and-enum-items // #show: correctly-indent-list-and-enum-items
// #show: dstu-style // Для рефератів, нестандартних робіт, тощо // #show: style.dstu
#show: pz-lb.with( #show: pz-lb.with(
..toml("/doc.toml"), ..toml("doc.toml"),
title: lorem(2), title: lorem(2),
) )
@@ -28,7 +31,7 @@ $ 1/2 dot 3 = 3/2 $
#lorem(20) #lorem(20)
#img("figures/Google-Logo-700x394.png", [Корпорація зла], width: 60%) // #img("/figures/Google-Logo-700x394.png", [Корпорація зла], width: 60%)
#lorem(50) #lorem(50)
@@ -48,4 +51,4 @@ $ 1/2 dot 3 = 3/2 $
#lorem(20) #lorem(20)
#appendices-style(include "appendices.typ") #style.appendices(include "chapters/appendices.typ")

View File

@@ -1,6 +1,9 @@
/// takes in a string of code, e.g. #code(read("foo.c")) /// takes in a string of code, e.g. #code(read("foo.c"))
#let code(content) = raw(block: true, theme: none, content) #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 /// include chapters by file names from /chapters
#let chapters(ch) = ( #let chapters(ch) = (
array(ch).map(chapter => include str(chapter) + ".typ").join() array(ch).map(chapter => include str(chapter) + ".typ").join()