about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-09-30 19:32:31 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-09-30 19:32:31 +0200
commit7a0003aff5262172700c5a10c53d91fa4421eec4 (patch)
tree5bfddd4e5a349fc0fbed05ac805287b6767b789e
parentchore(version): v0.7.3 (diff)
downloadflake-templates-7a0003aff5262172700c5a10c53d91fa4421eec4.tar.gz
flake-templates-7a0003aff5262172700c5a10c53d91fa4421eec4.zip
fix(templates/latex/{academia,letter}): Share files and update to lpm v2.0
-rw-r--r--common/.envrc9
-rw-r--r--common/flakes/latex/flake.nix126
-rwxr-xr-xcommon/scripts/latex/build.sh30
-rwxr-xr-xcommon/scripts/update.sh3
-rw-r--r--templates/latex/academia/%INIT_APPLICATION_NAME.tex16
l---------[-rw-r--r--]templates/latex/academia/.envrc10
l---------[-rw-r--r--]templates/latex/academia/flake.nix127
-rw-r--r--templates/latex/academia/lpm.toml22
l---------[-rwxr-xr-x]templates/latex/academia/update.sh4
l---------[-rw-r--r--]templates/latex/letter/.envrc10
l---------[-rw-r--r--]templates/latex/letter/flake.nix101
l---------[-rwxr-xr-x]templates/latex/letter/update.sh4
12 files changed, 196 insertions, 266 deletions
diff --git a/common/.envrc b/common/.envrc
new file mode 100644
index 0000000..3bc1085
--- /dev/null
+++ b/common/.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/common/flakes/latex/flake.nix b/common/flakes/latex/flake.nix
new file mode 100644
index 0000000..6a21c68
--- /dev/null
+++ b/common/flakes/latex/flake.nix
@@ -0,0 +1,126 @@
+{
+  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";
+      };
+    };
+    lpm = {
+      url = "git+https://codeberg.org/bpeetz/lpm.git";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+        flake-compat.follows = "flake-compat";
+        flake-utils.follows = "flake-utils";
+        rust-overlay.follows = "rust-overlay";
+        crane.follows = "crane";
+        systems.follows = "systems";
+      };
+    };
+
+    # 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";
+      };
+    };
+    crane = {
+      url = "github:ipetkov/crane";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
+    };
+    rust-overlay = {
+      url = "github:oxalica/rust-overlay";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+        flake-utils.follows = "flake-utils";
+      };
+    };
+  };
+
+  outputs = {
+    self,
+    nixpkgs,
+    flake-utils,
+    treefmt-nix,
+    lpm,
+    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/%INIT_APPLICATION_NAME.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
+          lpm.packages."${system}".default
+          texlive
+
+          zathura
+        ];
+      };
+    });
+}
diff --git a/common/scripts/latex/build.sh b/common/scripts/latex/build.sh
index 1206ee7..c67ad52 100755
--- a/common/scripts/latex/build.sh
+++ b/common/scripts/latex/build.sh
@@ -1,14 +1,30 @@
 #!/usr/bin/env sh
 
-# if no parameter is given, use 'dst' as destination directory
-if [ -z "$1" ]; then
-    dst=build
-else
-    dst="$1"
-fi
+file="./%INIT_APPLICATION_NAME.tex"
+dst=build
+
+clear=false
+
+for arg in "$@"; do
+    case "$arg" in
+    "--clear")
+        clear=true
+        ;;
+    --*)
+        echo "No such option: '$arg'"
+        exit 2
+        ;;
+    *)
+        file="$arg"
+        ;;
+    esac
+done
 
 # find all directories which are not the destination dir or inside it
 find . -type d -not -name "$dst" -not -path "./$dst/*" -printf '%P\n' | while IFS= read -r dir; do
     mkdir --parents "$dst/$dir"
 done
-latexmk -outdir="$dst" -file-line-error -pdflatex -recorder "./%INIT_APPLICATION_NAME.tex"
+
+test "$clear" = true && rm "$dst/${file%tex}out"
+
+latexmk -outdir="$dst" -file-line-error -pdflatex -recorder "$file"
diff --git a/common/scripts/update.sh b/common/scripts/update.sh
new file mode 100755
index 0000000..49216b8
--- /dev/null
+++ b/common/scripts/update.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+nix flake update
diff --git a/templates/latex/academia/%INIT_APPLICATION_NAME.tex b/templates/latex/academia/%INIT_APPLICATION_NAME.tex
index 5484bc6..b94aaa2 100644
--- a/templates/latex/academia/%INIT_APPLICATION_NAME.tex
+++ b/templates/latex/academia/%INIT_APPLICATION_NAME.tex
@@ -30,15 +30,17 @@
 \makeatother
 
 
-\includeonly{}
+\includeonly {
+    % lpm::next_chapter_includeonly_marker
+}
 
 \begin{document}
-    \onecolumn
-    \input{content/static/title}
-    \twocolumn
+\onecolumn
+\input{content/static/title}
+\twocolumn
 
-    % NEXT_CHAPTER
+% lpm::next_chapter_marker
 
-    \clearpage{}
-    \printbibliography\relax
+\clearpage{}
+\printbibliography\relax
 \end{document}
diff --git a/templates/latex/academia/.envrc b/templates/latex/academia/.envrc
index 3bc1085..db044c7 100644..120000
--- a/templates/latex/academia/.envrc
+++ b/templates/latex/academia/.envrc
@@ -1,9 +1 @@
-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
+../../../common/.envrc
\ No newline at end of file
diff --git a/templates/latex/academia/flake.nix b/templates/latex/academia/flake.nix
index 9a85d5d..3c2e48b 100644..120000
--- a/templates/latex/academia/flake.nix
+++ b/templates/latex/academia/flake.nix
@@ -1,126 +1 @@
-{
-  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";
-      };
-    };
-    lpm = {
-      url = "git+https://codeberg.org/bpeetz/lpm.git";
-      inputs = {
-        nixpkgs.follows = "nixpkgs";
-        flake-compat.follows = "flake-compat";
-        flake-utils.follows = "flake-utils";
-        rust-overlay.follows = "rust-overlay";
-        crane.follows = "crane";
-        systems.follows = "systems";
-      };
-    };
-
-    # 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";
-      };
-    };
-    crane = {
-      url = "github:ipetkov/crane";
-      inputs = {
-        nixpkgs.follows = "nixpkgs";
-      };
-    };
-    rust-overlay = {
-      url = "github:oxalica/rust-overlay";
-      inputs = {
-        nixpkgs.follows = "nixpkgs";
-        flake-utils.follows = "flake-utils";
-      };
-    };
-  };
-
-  outputs = {
-    self,
-    nixpkgs,
-    flake-utils,
-    treefmt-nix,
-    lpm,
-    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
-          lpm.packages."${system}".default
-          texlive
-
-          zathura
-        ];
-      };
-    });
-}
+../../../common/flakes/latex/flake.nix
\ No newline at end of file
diff --git a/templates/latex/academia/lpm.toml b/templates/latex/academia/lpm.toml
index d72f80f..1821b73 100644
--- a/templates/latex/academia/lpm.toml
+++ b/templates/latex/academia/lpm.toml
@@ -5,12 +5,30 @@ section = '''
 %! TEX root = ../../../%INIT_APPLICATION_NAME.tex
 % LTeX: language=%INIT_LANGUAGE
 
-\section{REPLACMENT_SECTION_TITLE} % DATE
+\section{lpm::new_section_name} % lpm::current_date (lpm::current_chapter_name::title_case)
 '''
 
 chapter = '''
 %! TEX root = ../../%INIT_APPLICATION_NAME.tex
 % LTeX: language=%INIT_LANGUAGE
 
-\chapter{REPLACEMENT_CHAPTER}
+\chapter{lpm::new_chapter_name} % lpm::current_date
+'''
+
+figure = '''
+% LTeX: language=%INIT_LANGUAGE
+\documentclass[varwidth]{standalone}
+
+\input{../headers/preamble.tex}
+\input{../headers/preamble_local.tex}
+
+\usepackage{tikz}
+
+\begin{document} % lpm::current_date (lpm::new_figure_name)
+
+\begin{tizkpicture}
+    \node at (0,0) {Hello world!};
+\end{tikzpicture}
+
+\end{document}
 '''
diff --git a/templates/latex/academia/update.sh b/templates/latex/academia/update.sh
index 49216b8..e84e4e3 100755..120000
--- a/templates/latex/academia/update.sh
+++ b/templates/latex/academia/update.sh
@@ -1,3 +1 @@
-#!/usr/bin/env sh
-
-nix flake update
+../../../common/scripts/update.sh
\ No newline at end of file
diff --git a/templates/latex/letter/.envrc b/templates/latex/letter/.envrc
index 3bc1085..db044c7 100644..120000
--- a/templates/latex/letter/.envrc
+++ b/templates/latex/letter/.envrc
@@ -1,9 +1 @@
-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
+../../../common/.envrc
\ No newline at end of file
diff --git a/templates/latex/letter/flake.nix b/templates/latex/letter/flake.nix
index 4847a9c..3c2e48b 100644..120000
--- a/templates/latex/letter/flake.nix
+++ b/templates/latex/letter/flake.nix
@@ -1,100 +1 @@
-{
-  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
-        ];
-      };
-    });
-}
+../../../common/flakes/latex/flake.nix
\ No newline at end of file
diff --git a/templates/latex/letter/update.sh b/templates/latex/letter/update.sh
index 49216b8..e84e4e3 100755..120000
--- a/templates/latex/letter/update.sh
+++ b/templates/latex/letter/update.sh
@@ -1,3 +1 @@
-#!/usr/bin/env sh
-
-nix flake update
+../../../common/scripts/update.sh
\ No newline at end of file