about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-03 20:52:28 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-03 20:53:04 +0200
commit87f57f8fd676d37b6aa5d1b3a85197ac59cb1eb4 (patch)
tree816c7ef5fdcf46f9d809a53203c5d0a7536858c7
parentfix(common/init): Actually ask the user for the license ident (diff)
downloadflake-templates-87f57f8fd676d37b6aa5d1b3a85197ac59cb1eb4.tar.gz
flake-templates-87f57f8fd676d37b6aa5d1b3a85197ac59cb1eb4.zip
feat(templates/latex/letter): Init
-rw-r--r--templates.nix4
-rw-r--r--templates/latex/letter/%INIT_APPLICATION_NAME.tex86
-rw-r--r--templates/latex/letter/.envrc9
-rw-r--r--templates/latex/letter/.gitignore8
l---------templates/latex/letter/.reuse1
l---------templates/latex/letter/README.md1
l---------templates/latex/letter/build.sh1
-rw-r--r--templates/latex/letter/cog.toml24
-rw-r--r--templates/latex/letter/flake.lock129
-rw-r--r--templates/latex/letter/flake.nix100
l---------templates/latex/letter/init1
l---------templates/latex/letter/scripts/cprh.sh1
l---------templates/latex/letter/scripts/extract_text_from_all.sh1
l---------templates/latex/letter/shell_line_editor.sh1
l---------templates/latex/letter/treefmt.nix1
-rwxr-xr-xtemplates/latex/letter/update.sh3
l---------templates/latex/letter/watch.sh1
17 files changed, 372 insertions, 0 deletions
diff --git a/templates.nix b/templates.nix
index 314810d..0ba4e77 100644
--- a/templates.nix
+++ b/templates.nix
@@ -29,6 +29,10 @@ in {
     Also **grep** for TODO marks after the `init` run and change them accordingly!
     Furthermore, please take a look at `lpm`.
   '';
+  latex_letter = mkAddedTemplate "latex/letter" ''
+    Also **grep** for TODO marks after the `init` run and change them accordingly!
+    Furthermore, please take a look at `lpm`.
+  '';
 
   # Currently unmaintained
   # markdown = mkDefaultTemplate "markdown";
diff --git a/templates/latex/letter/%INIT_APPLICATION_NAME.tex b/templates/latex/letter/%INIT_APPLICATION_NAME.tex
new file mode 100644
index 0000000..2037aa6
--- /dev/null
+++ b/templates/latex/letter/%INIT_APPLICATION_NAME.tex
@@ -0,0 +1,86 @@
+% LTeX: language=%INIT_LANGUAGE
+\documentclass[a4paper, version=last]{scrlttr2}
+\usepackage{lmodern}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[%INIT_BABLE_LANGUAGE]{babel}
+\usepackage{url}
+\usepackage[%INIT_DATE_TIME_LANGUAGE, showdow]{datetime2} % make handling dates easier
+
+\setkomafont{fromname}{\sffamily \LARGE}
+\setkomafont{fromaddress}{\sffamily}%% statt \small
+\setkomafont{pagenumber}{\sffamily}
+\setkomafont{subject}{\bfseries}
+\setkomafont{backaddress}{\mdseries}
+
+\LoadLetterOption{DIN}
+% \setkomavar{backaddressseparator}{\enspace\textperiodcentered\enspace}
+% \setkomavar{backaddress}{%INIT_AUTHOR_NAME\\ PO Box 8421\\ Bachbrecht\\10007\\ Namibia}
+\setkomavar{backaddressseparator}{ $\cdot$ }
+\setkomavar{customer}{2342}
+\setkomavar{date}{\DTMToday}
+\setkomavar{enclseparator}{: }
+\setkomavar{fromaddress}{Musterstraße 00\\00000 Musterort}
+\setkomavar{fromemail}{%INIT_AUTHOR_EMAIL}
+\setkomavar{fromname}{%INIT_AUTHOR_NAME}
+\setkomavar{fromphone}{+49 0000 00\,00\,00\,0}
+\setkomavar{place}{Musterort}
+\setkomavar{signature}{%INIT_AUTHOR_NAME}
+\setkomavar{subject}{%INIT_APPLICATION_NAME_STYLIZED}
+
+\renewcommand*{\raggedsignature}{\raggedright}
+
+\KOMAoptions{%
+    addrfield=true,           % Adress field for envelope with window
+    backaddress=true,         % Sender address in this window
+    enlargefirstpage=true,    % More space on first page
+    foldmarks=true,           % Print foldmarks?
+    footsepline=true,         % separate the footer with a line on page >1
+    fromalign=center,         % alignment of the address
+    % fromalign=right,          % Placement of name in letter head
+    fromemail=true,           % print sender e-mail address
+    fromfax=false,            % print sender fax number
+    fromlogo=false,           % print a logo (position depends on fromalign)
+    fromphone=true,           % print sender phone number
+    fromrule=afteraddress,    % separate the address with a line?
+    % fromrule=aftername,       % Rule after sender name in letter head
+    fromurl=false,            % print sender URL
+    headsepline=true,         % separate the header with a line on page >1
+    locfield=narrow,          % Additional field for sender
+    pagenumber=botright,      % position of the page number (see docu)
+    paper=a4,                 % pagesize
+    parskip=half,             % Use indent instead of skip
+    refline=wide,             % layout of the refline
+    subject=beforeopening,    % Placement of subject
+}
+
+\begin{document}
+
+\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road \\ Newport \\ Ipswich IP3 5RT}
+	\opening{Dear Sir or Madam,}
+
+	I am writing to you on behalf of the Wikipedia project
+	(\url{http://www.wikipedia.org/}), an endeavour to build a
+	fully-fledged multilingual encyclopaedia in an entirely open
+	manner, to ask for permission to use your copyrighted material.
+
+	\ldots
+
+	That said, allow me to reiterate that your material will be used
+	to the noble end of providing a free collection of knowledge for
+	everyone; naturally enough, only if you agree. If that is the
+	case, could you kindly fill in the attached form and post it back
+	to me? We shall greatly appreciate it.
+
+	Thank you for your time and consideration.
+
+	I look forward to your reply.
+
+	\closing{Yours Faithfully,}
+	\ps{P.S. You can find the full text of GFDL license at
+		\url{http://www.gnu.org/copyleft/fdl.html}.}
+	\encl{Copyright permission form}
+
+\end{letter}
+
+\end{document}
diff --git a/templates/latex/letter/.envrc b/templates/latex/letter/.envrc
new file mode 100644
index 0000000..3bc1085
--- /dev/null
+++ b/templates/latex/letter/.envrc
@@ -0,0 +1,9 @@
+use flake || use nix
+watch_file flake.nix
+
+PATH_add ./scripts
+
+if on_git_branch; then
+  echo && git status --short --branch &&
+  echo && git fetch --verbose
+fi
diff --git a/templates/latex/letter/.gitignore b/templates/latex/letter/.gitignore
new file mode 100644
index 0000000..539b891
--- /dev/null
+++ b/templates/latex/letter/.gitignore
@@ -0,0 +1,8 @@
+# build
+/result
+/build
+
+/resources.local
+
+# dev env
+.direnv
diff --git a/templates/latex/letter/.reuse b/templates/latex/letter/.reuse
new file mode 120000
index 0000000..d538161
--- /dev/null
+++ b/templates/latex/letter/.reuse
@@ -0,0 +1 @@
+../../../common/.reuse
\ No newline at end of file
diff --git a/templates/latex/letter/README.md b/templates/latex/letter/README.md
new file mode 120000
index 0000000..d250a7b
--- /dev/null
+++ b/templates/latex/letter/README.md
@@ -0,0 +1 @@
+../../../common/README.md
\ No newline at end of file
diff --git a/templates/latex/letter/build.sh b/templates/latex/letter/build.sh
new file mode 120000
index 0000000..4220aab
--- /dev/null
+++ b/templates/latex/letter/build.sh
@@ -0,0 +1 @@
+../../../common/scripts/latex/build.sh
\ No newline at end of file
diff --git a/templates/latex/letter/cog.toml b/templates/latex/letter/cog.toml
new file mode 100644
index 0000000..ccca764
--- /dev/null
+++ b/templates/latex/letter/cog.toml
@@ -0,0 +1,24 @@
+tag_prefix = "v"
+branch_whitelist = ["main", "prime"]
+ignore_merge_commits = false
+
+pre_bump_hooks = [
+  "nix flake check",                                                    # verify the project builds
+  "./scripts/renew_copyright_header.sh",                                # update the license header in each file
+  "flake_version_update --version v{{version}} --input-file flake.nix", # update the version in the flake.nix file
+  "nix fmt",                                                            # format
+]
+post_bump_hooks = [
+  "git push",
+  "git push origin v{{version}}", # push the new tag to origin
+]
+
+[bump_profiles]
+
+[changelog]
+path = "NEWS.md"
+template = "remote"
+remote = "%INIT_REMOTE"
+repository = "%INIT_REPOSITORY"
+owner = "%INIT_OWNER"
+authors = [{ signature = "%INIT_AUTHOR_NAME", username = "%INIT_OWNER" }]
diff --git a/templates/latex/letter/flake.lock b/templates/latex/letter/flake.lock
new file mode 100644
index 0000000..544cbdf
--- /dev/null
+++ b/templates/latex/letter/flake.lock
@@ -0,0 +1,129 @@
+{
+  "nodes": {
+    "flake-compat": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1696426674,
+        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+        "type": "github"
+      },
+      "original": {
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "type": "github"
+      }
+    },
+    "flake-utils": {
+      "inputs": {
+        "systems": [
+          "systems"
+        ]
+      },
+      "locked": {
+        "lastModified": 1710146030,
+        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flake_version_update": {
+      "inputs": {
+        "flake-utils": [
+          "flake-utils"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "systems": [
+          "systems"
+        ]
+      },
+      "locked": {
+        "lastModified": 1685288691,
+        "narHash": "sha256-oP6h34oJ8rm6KlUpyZrX+ww3hnoWny2ecrEXxkU7F3c=",
+        "ref": "refs/heads/prime",
+        "rev": "e9a97e01eca780bd16e1dbdbd8856b59558f4959",
+        "revCount": 5,
+        "type": "git",
+        "url": "https://codeberg.org/soispha/flake_version_update.git"
+      },
+      "original": {
+        "type": "git",
+        "url": "https://codeberg.org/soispha/flake_version_update.git"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1711715736,
+        "narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "807c549feabce7eddbf259dbdcec9e0600a0660d",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-compat": "flake-compat",
+        "flake-utils": "flake-utils",
+        "flake_version_update": "flake_version_update",
+        "nixpkgs": "nixpkgs",
+        "systems": "systems",
+        "treefmt-nix": "treefmt-nix"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1680978846,
+        "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
+        "owner": "nix-systems",
+        "repo": "x86_64-linux",
+        "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "x86_64-linux",
+        "type": "github"
+      }
+    },
+    "treefmt-nix": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1711803027,
+        "narHash": "sha256-Qic3OvsVLpetchzaIe2hJqgliWXACq2Oee6mBXa/IZQ=",
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "rev": "1810d51a015c1730f2fe05a255258649799df416",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/templates/latex/letter/flake.nix b/templates/latex/letter/flake.nix
new file mode 100644
index 0000000..4847a9c
--- /dev/null
+++ b/templates/latex/letter/flake.nix
@@ -0,0 +1,100 @@
+{
+  description = "%INIT_DESCRIPTION";
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
+    };
+    flake_version_update = {
+      url = "git+https://codeberg.org/soispha/flake_version_update.git";
+      inputs = {
+        systems.follows = "systems";
+        nixpkgs.follows = "nixpkgs";
+        flake-utils.follows = "flake-utils";
+      };
+    };
+
+    # inputs for following
+    systems = {
+      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
+    };
+    flake-compat = {
+      url = "github:edolstra/flake-compat";
+      flake = false;
+    };
+    flake-utils = {
+      url = "github:numtide/flake-utils";
+      inputs = {
+        systems.follows = "systems";
+      };
+    };
+  };
+
+  outputs = {
+    self,
+    nixpkgs,
+    flake-utils,
+    treefmt-nix,
+    flake_version_update,
+    ...
+  }:
+    flake-utils.lib.eachDefaultSystem (system: let
+      pkgs = nixpkgs.legacyPackages.${system};
+
+      # This version is set automatically on `cog bump --auto`;
+      version = "v%INIT_APPLICATION_VERSION"; # GUIDING VERSION STRING
+
+      # TODO reduce to the needed ones
+      texlive = pkgs.texlive.combined.scheme-full;
+
+      treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
+
+      build = pkgs.stdenv.mkDerivation {
+        pname = "%INIT_APPLICATION_NAME";
+        inherit version;
+        src = ./.;
+
+        buildInputs = [
+          texlive
+        ];
+
+        # Run local
+        preferLocalBuild = true;
+        allowSubstitutes = false;
+
+        buildPhase = ''
+          # TODO: I have no idea, why calling it with `./build.sh` does not work <2024-03-20>
+          bash ./build.sh
+        '';
+
+        installPhase = ''
+          install -D ./build/main.pdf "$out/%INIT_APPLICATION_NAME.pdf";
+        '';
+      };
+    in {
+      packages.default = build;
+
+      checks = {
+        inherit build;
+        formatting = treefmtEval.config.build.check self;
+      };
+
+      formatter = treefmtEval.config.build.wrapper;
+
+      devShells.default = pkgs.mkShell {
+        packages = with pkgs; [
+          cocogitto
+          reuse
+          flake_version_update.packages."${system}".default
+          texlive
+
+          zathura
+        ];
+      };
+    });
+}
diff --git a/templates/latex/letter/init b/templates/latex/letter/init
new file mode 120000
index 0000000..6b3141c
--- /dev/null
+++ b/templates/latex/letter/init
@@ -0,0 +1 @@
+../../../common/init
\ No newline at end of file
diff --git a/templates/latex/letter/scripts/cprh.sh b/templates/latex/letter/scripts/cprh.sh
new file mode 120000
index 0000000..03ffa2a
--- /dev/null
+++ b/templates/latex/letter/scripts/cprh.sh
@@ -0,0 +1 @@
+../../../../common/scripts/cprh.sh
\ No newline at end of file
diff --git a/templates/latex/letter/scripts/extract_text_from_all.sh b/templates/latex/letter/scripts/extract_text_from_all.sh
new file mode 120000
index 0000000..6c7f5a8
--- /dev/null
+++ b/templates/latex/letter/scripts/extract_text_from_all.sh
@@ -0,0 +1 @@
+../../../../common/scripts/latex/extract_text_from_all.sh
\ No newline at end of file
diff --git a/templates/latex/letter/shell_line_editor.sh b/templates/latex/letter/shell_line_editor.sh
new file mode 120000
index 0000000..e2ec043
--- /dev/null
+++ b/templates/latex/letter/shell_line_editor.sh
@@ -0,0 +1 @@
+../../../common/shell_line_editor.sh
\ No newline at end of file
diff --git a/templates/latex/letter/treefmt.nix b/templates/latex/letter/treefmt.nix
new file mode 120000
index 0000000..01b71f7
--- /dev/null
+++ b/templates/latex/letter/treefmt.nix
@@ -0,0 +1 @@
+../../../common/treefmt.nix
\ No newline at end of file
diff --git a/templates/latex/letter/update.sh b/templates/latex/letter/update.sh
new file mode 100755
index 0000000..49216b8
--- /dev/null
+++ b/templates/latex/letter/update.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+nix flake update
diff --git a/templates/latex/letter/watch.sh b/templates/latex/letter/watch.sh
new file mode 120000
index 0000000..fa5d4ea
--- /dev/null
+++ b/templates/latex/letter/watch.sh
@@ -0,0 +1 @@
+../../../common/scripts/latex/watch.sh
\ No newline at end of file