diff --git a/crude/.envrc b/crude/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/crude/.envrc @@ -0,0 +1 @@ +use flake diff --git a/crude/.gitignore b/crude/.gitignore new file mode 100644 index 0000000..726d2d6 --- /dev/null +++ b/crude/.gitignore @@ -0,0 +1,2 @@ +result +.direnv diff --git a/crude/flake.nix b/crude/flake.nix new file mode 100644 index 0000000..ee317bd --- /dev/null +++ b/crude/flake.nix @@ -0,0 +1,31 @@ +{ + description = "Extremely basic flake"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + packages = { + default = throw "put derivation information here"; + }; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + (throw "put packages here") + ]; + }; + + } + ); +} diff --git a/crude/template.typ b/crude/template.typ new file mode 100644 index 0000000..20ee568 --- /dev/null +++ b/crude/template.typ @@ -0,0 +1,182 @@ +#let crude( + title: if sys.inputs.keys().contains("title") { + sys.inputs.title + } else { + none + }, + author: if sys.inputs.keys().contains("author") { + sys.inputs.author + } else { + none + }, + sigil: if sys.inputs.keys().contains("sigil") { + sys.inputs.sigil + } else { + "sigil.svg" + }, + font: ( + text: { + if sys.inputs.keys().contains("font") { + let argFont = sys.inputs.font + if argFont == "mono" { + "Fira Mono" + } else if argFont == "sans" { + "Fira Sans" + } else if argFont == "orb" { + "Orbitron" + } else { + argFont + } + } else { + "Fira Sans" + } + }, + decoration: { + if sys.inputs.keys().contains("decoFont") { + let argFont = sys.inputs.decoFont + if argFont == "mono" { + "Fira Mono" + } else if argFont == "sans" { + "Fira Sans" + } else if argFont == "orb" { + "Orbitron" + } else { + argFont + } + } else { + "Orbitron" + } + } + ), + colors: if sys.inputs.keys().contains("colorScheme") { + let cs = sys.inputs.colorScheme + if cs == "light" { + ( + background: "ccccce", + foreground: "0d0d1b", + ) + } else if cs == "pink" { + ( + background: "0d0d1b", + foreground: "E60073" + ) + } else { + ( + background: "0d0d1b", + foreground: "ccccce", + ) + } + } else { + ( + background: "0d0d1b", + foreground: "ccccce", + ) + }, + nixPath: if sys.inputs.keys().contains("nixPath") { + sys.inputs.nixPath + } else { + "cd389898-51c9-53ee-8d27-4885055eed67" + }, + titleHash: if sys.inputs.keys().contains("titleHash") { + sys.inputs.titleHash + } else { + "ad3ebf6b-7c3a-5986-a46e-89777e5c2554" + }, + doc, +) = { + counter(page).update(0) + + set document( + title: title, + author: author + ) + + show heading: head => { + set text(font: font.decoration, 1.2em) + head + v(0.8em) + } + + show quote: q => { + set text(font: font.decoration) + q + } + + set quote( + block: true, + quotes: true + ) + + set page( + numbering: "I", + paper: "a4", + fill: color.rgb(colors.background), + header: context { + if counter(page).get().first() > 0 [ + #set text(font: font.decoration) + _#nixPath _ + #h(1fr) + *#document.author.join()* + ] + }, + footer: context { + if counter(page).get().first() > 0 [ + #set text(font: font.decoration) + *#(document.title, titleHash).join(" – ")* + #h(1fr) + #counter(page).display("I") + ] + } + ) + + set par( + justify: true + ) + + set text( + fill: color.rgb(colors.foreground), + font: (font.text, font.decoration), + lang: "en" + ) + + + figure( + image(sigil, width: 100%), + ) + + align(center)[ + #set text(font: font.decoration, 36pt, weight: "black") + #context { document.title } + ] + + align(center)[ + #set text(font: font.decoration, 24pt) + #context { document.author.join() } + ] + + let prependHash(color) = { + if color.first() != "#" { + upper("#" + color) + } else { + upper(color) + } + } + + v(1fr) + + context { + set text(font: font.decoration, 13pt) + align(right, ( + colors.values().map(x => prependHash(x)), + { if font.text != font.decoration { + (font.text, font.decoration).zip(("Text", "Decoration")).map(x => x.join(" - ")) + } else { + font.text + } }, + ).flatten().map(x => [#x]).join("\n") ) + } + + pagebreak() + + doc +} diff --git a/flake.nix b/flake.nix index c8b5334..e0a61bc 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,11 @@ description = "A basic Haskell flake"; }; + crude = { + path = ./crude; + description = "A somewhat 'crude' looking typst template"; + }; + }; defaultTemplate = self.templates.trivial; };