commit 573abbe7c322d8da086f54c58f39df30b784ec08 Author: Marius Drechsler Date: Sat May 17 14:42:57 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb6a416 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +result* +.direnv +.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..238c0b4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1747327360, + "narHash": "sha256-LSmTbiq/nqZR9B2t4MRnWG7cb0KVNU70dB7RT4+wYK4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e06158e58f3adee28b139e9c2bcfcc41f8625b46", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "typix": "typix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "typix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1746607658, + "narHash": "sha256-WKB6j7RddVr2NT1Wze03uw/yiFeEX/F5vdOWSKoj9Z0=", + "owner": "loqusion", + "repo": "typix", + "rev": "01160b19f90eeba0124dea8326779477b5313ebb", + "type": "github" + }, + "original": { + "owner": "loqusion", + "repo": "typix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d86201c --- /dev/null +++ b/flake.nix @@ -0,0 +1,96 @@ +{ + description = "A Typst project"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + typix = { + url = "github:loqusion/typix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + + # Example of downloading icons from a non-flake source + # font-awesome = { + # url = "github:FortAwesome/Font-Awesome"; + # flake = false; + # }; + }; + + outputs = inputs @ { + nixpkgs, + typix, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + inherit (pkgs) lib; + + typixLib = typix.lib.${system}; + + src = typixLib.cleanTypstSource ./.; + commonArgs = { + typstSource = "main.typ"; + + fontPaths = [ + # Add paths to fonts here + # "${pkgs.roboto}/share/fonts/truetype" + ]; + + virtualPaths = [ + # Add paths that must be locally accessible to typst here + # { + # dest = "icons"; + # src = "${inputs.font-awesome}/svgs/regular"; + # } + ]; + }; + + # Compile a Typst project, *without* copying the result + # to the current directory + build-drv = typixLib.buildTypstProject (commonArgs + // { + inherit src; + }); + + # Compile a Typst project, and then copy the result + # to the current directory + build-script = typixLib.buildTypstProjectLocal (commonArgs + // { + inherit src; + }); + + # Watch a project and recompile on changes + watch-script = typixLib.watchTypstProject commonArgs; + in { + checks = { + inherit build-drv build-script watch-script; + }; + + packages.default = build-drv; + + 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.typstfmt + ]; + }; + }); +} diff --git a/main.typ b/main.typ new file mode 100644 index 0000000..9083311 --- /dev/null +++ b/main.typ @@ -0,0 +1,2 @@ += Lorem ipsum +#lorem(30)