diff options
Diffstat (limited to 'overlays/kookie')
-rw-r--r-- | overlays/kookie/barrel-blog/default.nix | 32 | ||||
-rw-r--r-- | overlays/kookie/barrel-blog/meta.json | 6 | ||||
-rw-r--r-- | overlays/kookie/invoice/README.md | 54 | ||||
-rw-r--r-- | overlays/kookie/invoice/default.nix | 28 | ||||
-rwxr-xr-x | overlays/kookie/invoice/invoice.sh | 24 | ||||
-rw-r--r-- | overlays/kookie/invoice/template.tex | 141 | ||||
-rw-r--r-- | overlays/kookie/spacekookie-de/default.nix | 31 | ||||
-rw-r--r-- | overlays/kookie/spacekookie-de/meta.json | 6 |
8 files changed, 322 insertions, 0 deletions
diff --git a/overlays/kookie/barrel-blog/default.nix b/overlays/kookie/barrel-blog/default.nix new file mode 100644 index 00000000000..68e8cf1825f --- /dev/null +++ b/overlays/kookie/barrel-blog/default.nix @@ -0,0 +1,32 @@ +{ stdenv, fetchFromGitHub, pkgs, ... }: + +let + json = with builtins; fromJSON (readFile ./meta.json); + master = json.rev; + masterSha256 = json.sha256; +in + stdenv.mkDerivation rec { + name = "barrel-blog"; + + src = fetchFromGitHub { + owner = "spacekookie"; + repo = "barrel"; + rev = master; + sha256 = masterSha256; + }; + + buildInputs = with pkgs.pythonPackages; [ pelican webassets markdown ]; + + installPhase = '' + cd docs/ + pelican content + cp -rv output $out + ''; + + meta = with stdenv.lib; { + description = "A static website running on https://barrel.spacekookie.de"; + homepage = "https://barrel.spacekookie.de"; + license = licenses.mit; + }; + } + diff --git a/overlays/kookie/barrel-blog/meta.json b/overlays/kookie/barrel-blog/meta.json new file mode 100644 index 00000000000..3f1a908d973 --- /dev/null +++ b/overlays/kookie/barrel-blog/meta.json @@ -0,0 +1,6 @@ +{ + "owner": "spacekookie", + "repo": "barrel", + "rev": "ee5a17c97ac5315388f015ce59c98da3b6a895ce", + "sha256": "0n566x8y87pc3ynxqj7sv7cwsj4fhpz2pwn2mhhyjyqpyrq0khfc" +}
\ No newline at end of file diff --git a/overlays/kookie/invoice/README.md b/overlays/kookie/invoice/README.md new file mode 100644 index 00000000000..500fb5929fe --- /dev/null +++ b/overlays/kookie/invoice/README.md @@ -0,0 +1,54 @@ +# invoice + +A tool that generates invoices with `pandoc`, `xelatex` and `yaml`. +A descriptor file is required in order to make all of this work. +These are independent of the tooling and template and should be +client specific. Following is a small example of what it should +look like: + +```yaml +--- +invoice-nr: 2019-1234 +date: 2019-06-09 +author: Alice Anonymous +city: Metropolis +from: +- Cyberstreet 69 +- XX51F5 Metropolis +- alice.anonymous@mail.cyber +- + 69 (0) 13 37 13 12 +ustid: Your Tax ID here +bank: Evil Bank (i.e. a bank) +bank_iban: Your IBAN +bank_bic: Your Bank BIC +to: +- Client Name +- Client Address +- ... +VAT: 19 # Depends on the country you live in +service: +- description: Looking cool + price: 255 + details: + - Making all your other employees look silly + - Telling really bad jokes +- description: Being awesome + price: 615 + details: Its in the title! + +currency: EUR +lang: english + +# Typography and layout +fontsize: 10pt +geometry: a4paper, left=43mm, right=43mm, top=51mm, bottom=17mm +--- +``` + +Then point the script at this descriptor: + +``` +$ invoice clients/client_name.yml +``` + +This will then generate `clients/client_name.pdf` as an invoice diff --git a/overlays/kookie/invoice/default.nix b/overlays/kookie/invoice/default.nix new file mode 100644 index 00000000000..25c0fbb1ddb --- /dev/null +++ b/overlays/kookie/invoice/default.nix @@ -0,0 +1,28 @@ +{ stdenv, makeWrapper, coreutils, findutils, gawk, pandoc, gnumake, texlive }: + +stdenv.mkDerivation { + pname = "invoice"; + version = "0.1.0"; + src = ./.; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + mkdir -p $out/{bin,share} + cp invoice.sh $out/bin/invoice + cp template.tex $out/share/ + + wrapProgram $out/bin/invoice \ + --set PATH $out/bin:${stdenv.lib.makeBinPath + [ coreutils findutils gawk gnumake pandoc texlive.combined.scheme-full ]} \ + --set TEMPLATE_FILE $out/share/template.tex + ''; + + + meta = with stdenv.lib; { + description = "Generate dynamic invoices based on yaml descriptors"; + homepage = "https://git.sr.ht/~spacekookie/kookiepkgs/"; + license = licenses.gpl3; + }; +} + diff --git a/overlays/kookie/invoice/invoice.sh b/overlays/kookie/invoice/invoice.sh new file mode 100755 index 00000000000..1374f9219d2 --- /dev/null +++ b/overlays/kookie/invoice/invoice.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +set -ueo pipefail + +SOURCE=$1 + +if [ -z $SOURCE ]; then + echo "Usage: invoice <file>" + exit 2 +fi + +TARGET=$(dirname $SOURCE) +ACCOUNT=$(basename $SOURCE .yml) + +# The reason behind this awk madness is that we want to be able to write +# a date as yyyy-mm-dd in the invoice descriptor, but LaTeX needs the +# date as three elements to fill in a {d}{m}{y} pattern. Thus we replace +# a simple "date" line with three seperate fields that we can then read +# from LaTeX +cat $SOURCE | xargs -d '\n' -L 1 \ + | awk -F '-' '{ if(match($0, /date/)) { gsub(/date: /,"", $1); \ + print "date_year: " $1 "\n" "date_month: " $2 "\n" "date_day: " $3 } \ + else { print $0} }' \ + | pandoc - -o $TARGET/$ACCOUNT.pdf --template=$TEMPLATE_FILE --pdf-engine=xelatex diff --git a/overlays/kookie/invoice/template.tex b/overlays/kookie/invoice/template.tex new file mode 100644 index 00000000000..33d12f5f6dc --- /dev/null +++ b/overlays/kookie/invoice/template.tex @@ -0,0 +1,141 @@ +%!TEX TS-program = xelatex +%!TEX encoding = UTF-8 Unicode + +\documentclass[$fontsize$, a4paper]{scrartcl} + +% LAYOUT +%-------------------------------- +\usepackage{geometry} +\geometry{$geometry$} +\pagenumbering{gobble} +\usepackage[document]{ragged2e} +\usepackage{scrlayer-scrpage} + +% TYPOGRAPHY +%-------------------------------- +\usepackage{fontspec} +\usepackage{xunicode} +\usepackage{xltxtra} + +\setlength{\parskip}{1em} + +% Command required by how Pandoc handles the list conversion +\providecommand{\tightlist} { + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt} +} + +% TABLE CUSTOMIZATION +%-------------------------------- +\usepackage{spreadtab} +\usepackage[compact]{titlesec} +\usepackage{hhline} +\usepackage{enumitem} +\usepackage{arydshln} + +\titlespacing*{\section}{0pt}{3pt}{-7pt} +\renewcommand{\arraystretch}{1.5} +\setlist{nolistsep} +\setlist[itemize]{leftmargin=0.5cm} +\setlength{\tabcolsep}{9pt} + + +% LANGUAGE +%-------------------------------- +$if(lang)$ +\usepackage{polyglossia} +\setmainlanguage{german} +$endif$ + +% PDF SETUP +%-------------------------------- +\usepackage[xetex, bookmarks, colorlinks, breaklinks]{hyperref} +\hypersetup +{ + pdfauthor={$author$}, + pdfsubject=Rechnungs Nr. $invoice-nr$, + pdftitle=Rechnungs Nr. $invoice-nr$, + linkcolor=blue, + citecolor=blue, + filecolor=black, + urlcolor=blue +} + +\usepackage[nodayofweek]{datetime} +\newdate{date}{$date_day$}{$date_month$}{$date_year$} +\date{\displaydate{date}} + +% DOCUMENT +%-------------------------------- + +\ohead{ + \textsc{\textbf{$author$}} \\ + $for(from)$ + \textsc{$from$} \\ + $endfor$ + \textsc{USt-IdNr: $ustid$} \\ + \vspace{1em} +} + +\begin{document} + +\vspace{1em} + +\normalsize \sffamily +$for(to)$ +$to$\\ +$endfor$ + +\vspace{6em} + +\begin{flushright} + \small + $city$, \displaydate{date} +\end{flushright} + +\vspace{1em} + +\section*{\textsc{Rechnung} \textsc{\#$invoice-nr$}} +\footnotesize +\newcounter{pos} +\setcounter{pos}{0} +\STautoround*{2} % Get spreadtab to always display the decimal part +$if(commasep)$\STsetdecimalsep{,}$endif$ % Use comma as decimal separator + +\begin{spreadtab}{{tabular}[t t t]{lp{8.2cm}r}} + \hdashline[1pt/1pt] + @ \noalign{\vskip 2mm} \textbf{Pos.} & @ \textbf{Description} & @ \textbf{Prices in $currency$} \\ \hline + $for(service)$ @ \noalign{\vskip 2mm} \refstepcounter{pos} \thepos + & @ $service.description$ + $if(service.details)$\newline \begin{itemize} + $for(service.details)$\scriptsize \item $service.details$ + $endfor$ \end{itemize} + $endif$ & $service.price$\\$endfor$ \noalign{\vskip 2mm} \hline + $if(VAT)$ + @ & @ \multicolumn{1}{r}{Subtotal:} & :={sum(c1:[0,-1])} \\ \hhline{~~-} + @ & @ \multicolumn{1}{r}{VAT $VAT$\%:} & $VAT$/100*[0,-1] \\ \hhline{~~-} + $else$ + @ & @ \multicolumn{1}{r}{Subtotal:} & :={sum(c1:[0,-1])} \\ \hhline{~~-} + @ & @ \multicolumn{1}{r}{USt. Nullregelung:} & 0 \\ \hhline{~~-} + $endif$ + @ & @ \multicolumn{1}{r}{\textbf{Total:}} & \textbf{:={$if(VAT)$[0,-1]+[0,-2]$else$[0,-2]$endif$}} \\ \hhline{~~-} +\end{spreadtab} + +\vspace{15mm} + +\sffamily +\small + +Bitte überweisen Sie den folgenden Betrag in den nächsten 14 Tagen: + +\strong{Kontoinhaber}: $author$ \\ +\strong{Kreditinstitut}: $bank$ \\ +\strong{IBAN}: $bank_iban$ \\ +\strong{BIC}: $bank_bic$ + +Mit freundlichen Grüßen, + +\medskip + +$author$ + +\end{document} diff --git a/overlays/kookie/spacekookie-de/default.nix b/overlays/kookie/spacekookie-de/default.nix new file mode 100644 index 00000000000..a15af12b5fa --- /dev/null +++ b/overlays/kookie/spacekookie-de/default.nix @@ -0,0 +1,31 @@ +{ stdenv, fetchFromGitHub, pkgs, ... }: + +let + json = with builtins; fromJSON (readFile ./meta.json); + master = json.rev; + masterSha256 = json.sha256; +in + stdenv.mkDerivation rec { + name = "spacekookie.de"; + + src = fetchFromGitHub { + owner = "spacekookie"; + repo = "website"; + rev = master; + sha256 = masterSha256; + }; + + buildInputs = with pkgs.python3Packages; [ pelican webassets markdown ]; + + installPhase = '' + pelican content + cp -rv output $out + ''; + + meta = with stdenv.lib; { + description = "The `about` and `blog` part of spacekookie.de"; + homepage = "https://spacekookie.de"; + license = licenses.mit; + }; + } + diff --git a/overlays/kookie/spacekookie-de/meta.json b/overlays/kookie/spacekookie-de/meta.json new file mode 100644 index 00000000000..a793b45c5a6 --- /dev/null +++ b/overlays/kookie/spacekookie-de/meta.json @@ -0,0 +1,6 @@ +{ + "owner": "spacekookie", + "repo": "website", + "rev": "beb5a1bbd298ceb1646902cc3ee7255f50f54542", + "sha256": "1nhcp87ixnfalir8bi3gnx4q30f2dava0g6przzkp2mkdiwnh1fm" +}
\ No newline at end of file |