diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..bc49353 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake .# diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index a1fdab5..03d687f 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -3,92 +3,45 @@ name: Build and Release # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch on: - push: - paths: - - "**.tex" - - "**.yml" - - "**.sty" - branches: [ master ] - pull_request: - paths: - - "**.tex" - - "**.yml" - - "**.sty" - branches: [ master ] + - push + - pull_request # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build: name: Build all files runs-on: ubuntu-latest - container: - image: ghcr.io/xu-cheng/texlive-small:latest - defaults: - run: - shell: sh steps: - - name: Set up repo - uses: actions/checkout@v2 - - name: Install missing packages - run: | - tlmgr update --self && tlmgr install --force --reinstall silence appendixnumberbeamer fira fontaxes mwe noto csquotes fontspec babel luatexja haranoaji haranoaji-extra --repository http://ftp.fau.de/ctan/systems/texlive/tlnet/ - - name: Build minimal examples with pdfLaTeX - working-directory: minimal_examples/ - run: | - ln -sf ../*.sty ./ - ln -sf ../logos ./ - latexmk -pdf -file-line-error -interaction=nonstopmode *.tex - - name: Remove pdfLaTeX results if compilation succeeds - working-directory: minimal_examples/ - run: rm *.pdf - - name: Build minimal examples with LuaLaTeX - working-directory: minimal_examples/ - run: | - ln -sf ../*.sty ./ - ln -sf ../logos ./ - latexmk -lualatex -file-line-error -interaction=nonstopmode *.tex - - name: Build multi-language examples with LuaLaTeX - working-directory: multi_lang_examples/ - run: | - ln -sf ../*.sty ./ - ln -sf ../logos ./ - latexmk -lualatex -file-line-error -interaction=nonstopmode *.tex - - name: Build compare examples - working-directory: compare_examples/ - run: | - ln -sf ../*.sty ./ - ln -sf ../logos ./ - latexmk -pdf -file-line-error -interaction=nonstopmode *example*.tex - - name: Build demo document - run: | - latexmk -pdf -file-line-error -interaction=nonstopmode beamertheme-pure-minimalistic-demo.tex - - name: PDFs to PNGs - uses: docker://frapsoft/fish:latest - with: - args: fish ./.github/workflows/convert_pdf_to_png.fish - if: github.event_name == 'push' - - name: Sync docs - uses: kai-tub/external-repo-sync-action@v1 - with: - source-directory: "./" - include-patterns: "beamertheme-pure-minimalistic-demo.pdf *.png" - exclude-patterns: "*.tmp.png logos" - commit-message: "Updating LaTeX documentation files" - env: - GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} - if: github.event_name == 'push' - release: - name: Release new version - runs-on: ubuntu-latest + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Run tests + run: nix flake check -L + publish: + name: Publish needs: build - if: github.event_name == 'push' + runs-on: ubuntu-latest + permissions: + contents: write + if: startsWith(github.ref, 'refs/tags/') steps: - - name: Set up Git - uses: actions/checkout@v2 - - name: Prepare repository - run: git fetch --unshallow --tags - - name: Run release script - run: bash auto_scripts/run_auto.sh - env: - # To be able to trigger next event - GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + # only execute if a new release is created + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - run: nix build .#documentation-artifacts + - uses: actions/checkout@v4 + with: + repository: kai-tub/latex-beamer-pure-minimalistic.wiki.git + path: wiki + - run: | + echo "Copy documentation results to wiki" + cp -r ./result wiki/ + cd wiki + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "update wiki" + echo "annotate release if release triggered the workflow" + git tag --annotate --message "Release" ${{ github.ref_name }} + git push diff --git a/.github/workflows/convert_pdf_to_png.fish b/.github/workflows/convert_pdf_to_png.fish deleted file mode 100644 index 17f130c..0000000 --- a/.github/workflows/convert_pdf_to_png.fish +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/fish - -function convert_minimal_examples - set files (find ./minimal_examples -type d -path '*/.git' -prune -o -name '*.pdf' -print) - for file_ in $files - echo "$file_" - set target (string replace '.pdf' '.png' "$file_") - convert -density 500 "$file_"[0] "$target" - end -end - -function convert_compare_examples - set files (find ./compare_examples -type d -path '*/.git' -prune -o -name '*example*.pdf' -print) - - for file_ in $files - echo "$file_" - set convert_target (string replace -r '(.*)\.pdf' '$1-%02d.tmp.png' "$file_") - set montage_source (string replace -r '(.*)\.pdf' '$1-*.png' "$file_") - set montage_target (string replace -r '(.*)\.pdf' '$1.tmp.png' "$file_") - convert -density 300 "$file_" "$convert_target" - montage "$montage_source" -geometry +10+10 -tile 1x -background gray -colorspace RGB "$montage_target" - # maybe next to each other - end - montage ./compare_examples/pureminimalistic_example_dark.tmp.png ./compare_examples/defaultbeamer_example.tmp.png -geometry +2+2 -tile 2x -background gray ./compare_examples/comparison_dark.png - montage ./compare_examples/pureminimalistic_example_light.tmp.png ./compare_examples/defaultbeamer_example.tmp.png -geometry +2+2 -tile 2x -background gray ./compare_examples/comparison_light.png -end - -function convert_multi_lang_examples - set files (find ./multi_lang_examples -type d -path '*/.git' -prune -o -name '*.lua.pdf' -print) - - for file_ in $files - echo "$file_" - set convert_target (string replace -r '(.*)\.pdf' '$1-%02d.tmp.png' "$file_") - set montage_source (string replace -r '(.*)\.pdf' '$1-*.png' "$file_") - set montage_target (string replace -r '(.*)\.pdf' '$1.tmp.png' "$file_") - convert -density 300 "$file_" "$convert_target" - montage "$montage_source" -geometry +10+10 -tile 1x -background gray -colorspace RGB "$montage_target" - end - montage ./multi_lang_examples/*.pdf -geometry +2+2 -tile 2x -background gray ./multi_lang_examples/lang_comparison.png -end - -function convert_demo - convert -density 300 beamertheme-pure-minimalistic-demo.pdf beamertheme-pure-minimalistic-demo-%02d.tmp.png - montage beamertheme-pure-minimalistic-demo-*.png -geometry +10+10 -tile 4x -background gray beamertheme-pure-minimalistic-demo.png -end - -apk add --no-cache imagemagick - -convert_demo -convert_minimal_examples -convert_compare_examples -convert_multi_lang_examples \ No newline at end of file diff --git a/.gitignore b/.gitignore index 262136e..975dc6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ # cannot link to sty for windows support +result +.direnv minimal_examples/*.sty minimal_examples/*.pdf minimal_examples/logos diff --git a/auto_scripts/README.md b/auto_scripts/README.md deleted file mode 100644 index aad3fa3..0000000 --- a/auto_scripts/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Auto scripts - -These scripts are used to build the release automatically. -The [auto](https://intuit.github.io/auto/) tool bumps the tag version -and publishes the release on GitHub. The configuration file is the -[.autorc](../.autorc) file in the root project folder. During the -release process, auto will trigger the [update_package_versioning](update_package_versioning.sh) -script. This script replaces the version specification in the `.sty` files with the -newest release. The previous version is ignored and replaced with the currently published version. - -If the version `v1.1.2` is currently being published, it will change - -```latex -\ProvidesPackage{pureminimalistic}[XXX] -``` -to -```latex -\ProvidesPackage{pureminimalistic}[v1.1.2] -``` - -It will not check what was written between the square brackets. -This aggressive replace feature makes it robust against accidental manual changes. diff --git a/auto_scripts/run_auto.sh b/auto_scripts/run_auto.sh deleted file mode 100644 index ecddf02..0000000 --- a/auto_scripts/run_auto.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Download and run the `auto` tool -> With the provided .autorc file, -# it will trigger a call to update_package_versioning.sh -curl -kL -o - https://github.com/intuit/auto/releases/latest/download/auto-linux.gz | gunzip > ~/auto -chmod a+x ~/auto -~/auto shipit diff --git a/auto_scripts/semvertool.sh b/auto_scripts/semvertool.sh deleted file mode 100644 index b6d2be3..0000000 --- a/auto_scripts/semvertool.sh +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/env bash - -# https://github.com/fsaintjacques/semver-tool -# Copyright (c) 2014-2015 François Saint-Jacques -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program. If not, see . - -set -o errexit -o nounset -o pipefail - -NAT='0|[1-9][0-9]*' -ALPHANUM='[0-9]*[A-Za-z-][0-9A-Za-z-]*' -IDENT="$NAT|$ALPHANUM" -FIELD='[0-9A-Za-z-]+' - -SEMVER_REGEX="\ -^[vV]?\ -($NAT)\\.($NAT)\\.($NAT)\ -(\\-(${IDENT})(\\.(${IDENT}))*)?\ -(\\+${FIELD}(\\.${FIELD})*)?$" - -PROG=semver -PROG_VERSION="3.0.0" - -USAGE="\ -Usage: - $PROG bump (major|minor|patch|release|prerel |build ) - $PROG compare - $PROG get (major|minor|patch|release|prerel|build) - $PROG --help - $PROG --version -Arguments: - A version must match the following regular expression: - \"${SEMVER_REGEX}\" - In English: - -- The version must match X.Y.Z[-PRERELEASE][+BUILD] - where X, Y and Z are non-negative integers. - -- PRERELEASE is a dot separated sequence of non-negative integers and/or - identifiers composed of alphanumeric characters and hyphens (with - at least one non-digit). Numeric identifiers must not have leading - zeros. A hyphen (\"-\") introduces this optional part. - -- BUILD is a dot separated sequence of identifiers composed of alphanumeric - characters and hyphens. A plus (\"+\") introduces this optional part. - See definition. - A string as defined by PRERELEASE above. - A string as defined by BUILD above. -Options: - -v, --version Print the version of this tool. - -h, --help Print this help message. -Commands: - bump Bump by one of major, minor, patch; zeroing or removing - subsequent parts. \"bump prerel\" sets the PRERELEASE part and - removes any BUILD part. \"bump build\" sets the BUILD part. - \"bump release\" removes any PRERELEASE or BUILD parts. - The bumped version is written to stdout. - compare Compare with , output to stdout the - following values: -1 if is newer, 0 if equal, 1 if - older. The BUILD part is not used in comparisons. - get Extract given part of , where part is one of major, minor, - patch, prerel, build, or release. -See also: - https://semver.org -- Semantic Versioning 2.0.0" - -function error { - echo -e "$1" >&2 - exit 1 -} - -function usage-help { - error "$USAGE" -} - -function usage-version { - echo -e "${PROG}: $PROG_VERSION" - exit 0 -} - -function validate-version { - local version=$1 - if [[ "$version" =~ $SEMVER_REGEX ]]; then - # if a second argument is passed, store the result in var named by $2 - if [ "$#" -eq "2" ]; then - local major=${BASH_REMATCH[1]} - local minor=${BASH_REMATCH[2]} - local patch=${BASH_REMATCH[3]} - local prere=${BASH_REMATCH[4]} - local build=${BASH_REMATCH[8]} - eval "$2=(\"$major\" \"$minor\" \"$patch\" \"$prere\" \"$build\")" - else - echo "$version" - fi - else - error "version $version does not match the semver scheme 'X.Y.Z(-PRERELEASE)(+BUILD)'. See help for more information." - fi -} - -function is-nat { - [[ "$1" =~ ^($NAT)$ ]] -} - -function is-null { - [ -z "$1" ] -} - -function order-nat { - [ "$1" -lt "$2" ] && { echo -1 ; return ; } - [ "$1" -gt "$2" ] && { echo 1 ; return ; } - echo 0 -} - -function order-string { - [[ $1 < $2 ]] && { echo -1 ; return ; } - [[ $1 > $2 ]] && { echo 1 ; return ; } - echo 0 -} - -# given two (named) arrays containing NAT and/or ALPHANUM fields, compare them -# one by one according to semver 2.0.0 spec. Return -1, 0, 1 if left array ($1) -# is less-than, equal, or greater-than the right array ($2). The longer array -# is considered greater-than the shorter if the shorter is a prefix of the longer. -# -function compare-fields { - local l="$1[@]" - local r="$2[@]" - local leftfield=( "${!l}" ) - local rightfield=( "${!r}" ) - local left - local right - - local i=$(( -1 )) - local order=$(( 0 )) - - while true - do - [ $order -ne 0 ] && { echo $order ; return ; } - - : $(( i++ )) - left="${leftfield[$i]}" - right="${rightfield[$i]}" - - is-null "$left" && is-null "$right" && { echo 0 ; return ; } - is-null "$left" && { echo -1 ; return ; } - is-null "$right" && { echo 1 ; return ; } - - is-nat "$left" && is-nat "$right" && { order=$(order-nat "$left" "$right") ; continue ; } - is-nat "$left" && { echo -1 ; return ; } - is-nat "$right" && { echo 1 ; return ; } - { order=$(order-string "$left" "$right") ; continue ; } - done -} - -# shellcheck disable=SC2206 # checked by "validate"; ok to expand prerel id's into array -function compare-version { - local order - validate-version "$1" V - validate-version "$2" V_ - - # compare major, minor, patch - - local left=( "${V[0]}" "${V[1]}" "${V[2]}" ) - local right=( "${V_[0]}" "${V_[1]}" "${V_[2]}" ) - - order=$(compare-fields left right) - [ "$order" -ne 0 ] && { echo "$order" ; return ; } - - # compare pre-release ids when M.m.p are equal - - local prerel="${V[3]:1}" - local prerel_="${V_[3]:1}" - local left=( ${prerel//./ } ) - local right=( ${prerel_//./ } ) - - # if left and right have no pre-release part, then left equals right - # if only one of left/right has pre-release part, that one is less than simple M.m.p - - [ -z "$prerel" ] && [ -z "$prerel_" ] && { echo 0 ; return ; } - [ -z "$prerel" ] && { echo 1 ; return ; } - [ -z "$prerel_" ] && { echo -1 ; return ; } - - # otherwise, compare the pre-release id's - - compare-fields left right -} - -function command-bump { - local new; local version; local sub_version; local command; - - case $# in - 2) case $1 in - major|minor|patch|release) command=$1; version=$2;; - *) usage-help;; - esac ;; - 3) case $1 in - prerel|build) command=$1; sub_version=$2 version=$3 ;; - *) usage-help;; - esac ;; - *) usage-help;; - esac - - validate-version "$version" parts - # shellcheck disable=SC2154 - local major="${parts[0]}" - local minor="${parts[1]}" - local patch="${parts[2]}" - local prere="${parts[3]}" - local build="${parts[4]}" - - case "$command" in - major) new="$((major + 1)).0.0";; - minor) new="${major}.$((minor + 1)).0";; - patch) new="${major}.${minor}.$((patch + 1))";; - release) new="${major}.${minor}.${patch}";; - prerel) new=$(validate-version "${major}.${minor}.${patch}-${sub_version}");; - build) new=$(validate-version "${major}.${minor}.${patch}${prere}+${sub_version}");; - *) usage-help ;; - esac - - echo "$new" - exit 0 -} - -function command-compare { - local v; local v_; - - case $# in - 2) v=$(validate-version "$1"); v_=$(validate-version "$2") ;; - *) usage-help ;; - esac - - set +u # need unset array element to evaluate to null - compare-version "$v" "$v_" - exit 0 -} - - -# shellcheck disable=SC2034 -function command-get { - local part version - - if [[ "$#" -ne "2" ]] || [[ -z "$1" ]] || [[ -z "$2" ]]; then - usage-help - exit 0 - fi - - part="$1" - version="$2" - - validate-version "$version" parts - local major="${parts[0]}" - local minor="${parts[1]}" - local patch="${parts[2]}" - local prerel="${parts[3]:1}" - local build="${parts[4]:1}" - local release="${major}.${minor}.${patch}" - - case "$part" in - major|minor|patch|release|prerel|build) echo "${!part}" ;; - *) usage-help ;; - esac - - exit 0 -} - -case $# in - 0) echo "Unknown command: $*"; usage-help;; -esac - -case $1 in - --help|-h) echo -e "$USAGE"; exit 0;; - --version|-v) usage-version ;; - bump) shift; command-bump "$@";; - get) shift; command-get "$@";; - compare) shift; command-compare "$@";; - *) echo "Unknown arguments: $*"; usage-help;; -esac \ No newline at end of file diff --git a/auto_scripts/update_package_versioning.sh b/auto_scripts/update_package_versioning.sh deleted file mode 100644 index 24794d3..0000000 --- a/auto_scripts/update_package_versioning.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# Script is triggered by `auto` BeforeChangelog -# Assumes current dir is the project root - -set -e - -# Print on stderr to not pollute function return echo -function error { - echo "::error::$1" >& 2 - exit 1 -} - -# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself -scriptFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -bumpType=$(echo "$ARG_0" | jq -r '.bump') -currentVersion=$( echo "$ARG_0" | jq -r '.currentVersion' ) - -echo "currentVersion: $currentVersion" -echo "bump type: $bumpType" - - -if [[ -z "$currentVersion" ]]; then - error "auto provided empty ENV json!" -fi - -# bump version -newVersion=$( bash "${scriptFolder}/semvertool.sh" bump "$bumpType" "$currentVersion" ) -newVersionWithV="v$newVersion" - -sed -r -i "s/(\\ProvidesPackage\{\w+\})\[.*\]/\1\[${newVersionWithV}\]/g" -- *.sty -# Files will be commited via `auto` tool -git add . diff --git a/beamerfontthemepureminimalistic.sty b/beamerfontthemepureminimalistic.sty index 0841ce8..3a6605d 100644 --- a/beamerfontthemepureminimalistic.sty +++ b/beamerfontthemepureminimalistic.sty @@ -51,6 +51,7 @@ }{% \ifthenelse{\boolean{customfont}}{% % Load default fonts + \RequirePackage{lmodern} }{% % By default load Fira \RequirePackage[sfdefault]{FiraSans} diff --git a/compare_examples/defaultbeamer_example.tex b/compare_examples/defaultbeamer_example.tex index 31db499..93fee28 100644 --- a/compare_examples/defaultbeamer_example.tex +++ b/compare_examples/defaultbeamer_example.tex @@ -1,5 +1,5 @@ -\input{common_header_input.tex} +\input{inputs/common_header_input.tex} \begin{document} - \input{common_slides_input.tex} + \input{inputs/common_slides_input.tex} \end{document} diff --git a/compare_examples/common_header_input.tex b/compare_examples/inputs/common_header_input.tex similarity index 100% rename from compare_examples/common_header_input.tex rename to compare_examples/inputs/common_header_input.tex diff --git a/compare_examples/common_slides_input.tex b/compare_examples/inputs/common_slides_input.tex similarity index 100% rename from compare_examples/common_slides_input.tex rename to compare_examples/inputs/common_slides_input.tex diff --git a/compare_examples/pureminimalistic_example_dark.tex b/compare_examples/pureminimalistic_example_dark.tex index e81723a..1a5982a 100644 --- a/compare_examples/pureminimalistic_example_dark.tex +++ b/compare_examples/pureminimalistic_example_dark.tex @@ -1,6 +1,6 @@ -\input{common_header_input.tex} +\input{inputs/common_header_input.tex} \usetheme[darkmode]{pureminimalistic} \begin{document} - \input{common_slides_input.tex} + \input{inputs/common_slides_input.tex} \end{document} diff --git a/compare_examples/pureminimalistic_example_light.tex b/compare_examples/pureminimalistic_example_light.tex index da0bd4f..7d9de91 100644 --- a/compare_examples/pureminimalistic_example_light.tex +++ b/compare_examples/pureminimalistic_example_light.tex @@ -1,6 +1,6 @@ -\input{common_header_input.tex} +\input{inputs/common_header_input.tex} \usetheme{pureminimalistic} \begin{document} - \input{common_slides_input.tex} + \input{inputs/common_slides_input.tex} \end{document} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5d4e324 --- /dev/null +++ b/flake.lock @@ -0,0 +1,143 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1717408969, + "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", + "owner": "numtide", + "repo": "devshell", + "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1710156097, + "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "3342559a24e85fc164b295c3444e8a139924675b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1718543737, + "narHash": "sha256-e8S/ODM1vkKHIexSVn9nIvne7vRO5M+35VAq/6JOYto=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "683aa7c4e385509ca651d49eeb35e58c7a1baad6", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "nix-filter": "nix-filter", + "nixpkgs": "nixpkgs_2", + "systems": "systems_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a650000 --- /dev/null +++ b/flake.nix @@ -0,0 +1,162 @@ +{ + description = "Nix related tooling for a command line interface for audible. With the CLI you can download your Audible books, cover, chapter files & conver them."; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/x86_64-linux"; + flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; + nix-filter.url = "github:numtide/nix-filter"; + devshell.url = "github:numtide/devshell"; + }; + outputs = { + self, + nixpkgs, + systems, + ... + } @ inputs: let + eachSystem = nixpkgs.lib.genAttrs (import systems); + pkgsFor = eachSystem (system: (nixpkgs.legacyPackages.${system}.extend inputs.devshell.overlays.default)); + tex-deps-builder = texlive-pkg: (texlive-pkg.combine { + inherit + (texlive-pkg) + scheme-small + beamer + latex-bin + latexmk + silence + appendixnumberbeamer + fira + fontaxes + mwe + noto + csquotes + fontspec + infwarerr + kvoptions + # only for demo + + biblatex + biber + # only for language examples + + haranoaji + haranoaji-extra + babel + luatexja + # without \RequirePackage{lmodern} and without cm-super + + # Otherwise I was getting errors: 3/bin/pdflatex (file ecss0800): Font ecss0800 at 600 not found + + # https://tex.stackexchange.com/questions/267675/pdftex-error-pdflatex-file-ecbx0800-font-ecbx0800-at-600-not-found + + cm-super + ; + }); + in { + formatter = eachSystem (system: pkgsFor.${system}.alejandra); + checks = eachSystem (system: self.packages.${system}); + # should probably be call package + packages = eachSystem (system: let + pkgs = pkgsFor.${system}; + in rec { + demo-pdflatex = pkgs.callPackage nix/default.nix { + inherit self; + nix-filter = inputs.nix-filter; + tex-deps = tex-deps-builder pkgs.texlive; + tex-directory = "."; + }; + demo-pdflatex-montage = + pkgs.runCommand "demo-pdflatex-pdf" { + src = ./scripts; + buildInputs = [demo-pdflatex pkgs.nushell pkgs.imagemagickBig]; + } '' + mkdir $out + nu --no-history --no-config-file \ + $src/create_pngs.nu create-montage demo \ + --src-dir ${demo-pdflatex} --target-dir $out + ''; + minimal-examples-pdflatex = pkgs.callPackage nix/default.nix { + inherit self; + nix-filter = inputs.nix-filter; + tex-deps = tex-deps-builder pkgs.texlive; + tex-directory = "minimal_examples"; + }; + minimal-examples-lualatex = pkgs.callPackage nix/default.nix { + inherit self; + nix-filter = inputs.nix-filter; + tex-deps = tex-deps-builder pkgs.texlive; + use-lualatex = true; + tex-directory = "minimal_examples"; + }; + minimal-examples-pngs = + pkgs.runCommand "minimal-examples-pngs" { + src = ./scripts; + buildInputs = [minimal-examples-lualatex pkgs.nushell pkgs.imagemagickBig]; + } '' + mkdir $out + nu --no-history --no-config-file \ + $src/create_pngs.nu convert-pdfs-to-pngs \ + --src-dir ${minimal-examples-lualatex} --target-dir $out --density 600 + + ''; + compare-examples = pkgs.callPackage nix/default.nix { + inherit self; + nix-filter = inputs.nix-filter; + tex-deps = tex-deps-builder pkgs.texlive; + use-lualatex = true; + tex-directory = "compare_examples"; + }; + # what is runCommand ? + # just need to call command and provide the given input and output dir! + compare-examples-montage = + pkgs.runCommand "compare-examples-pdf" { + src = ./scripts; + buildInputs = [compare-examples pkgs.nushell pkgs.imagemagickBig]; + } '' + mkdir $out + nu --no-history --no-config-file \ + $src/create_pngs.nu create-montage compare_examples \ + --src-dir ${compare-examples} --target-dir $out + ''; + multi-lang-examples = pkgs.callPackage nix/default.nix { + inherit self; + nix-filter = inputs.nix-filter; + tex-deps = tex-deps-builder pkgs.texlive; + use-lualatex = true; + tex-directory = "multi_lang_examples"; + }; + multi-lang-examples-montage = + pkgs.runCommand "multi-lang-examples-pdf" { + src = ./scripts; + buildInputs = [multi-lang-examples pkgs.nushell pkgs.imagemagickBig]; + } '' + mkdir $out + nu --no-history --no-config-file \ + $src/create_pngs.nu create-montage multi_lang_examples \ + --src-dir ${multi-lang-examples} --target-dir $out + ''; + documentation-artifacts = pkgs.symlinkJoin { + name = "documentation-artifacts"; + paths = [ + multi-lang-examples-montage + compare-examples-montage + demo-pdflatex-montage + minimal-examples-pngs + minimal-examples-lualatex + ]; + }; + }); + devShells = eachSystem ( + system: let + pkgs = pkgsFor.${system}; + in { + default = pkgs.devshell.mkShell { + packages = [ + (tex-deps-builder pkgs.texlive) + pkgs.imagemagickBig + pkgs.fd + ]; + }; + } + ); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..522c5df --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,76 @@ +{ + self, + lib, + stdenvNoCC, + nix-filter, + coreutils, + findutils, + version ? "git", + tex-deps, + use-lualatex ? false, + use-pdflatex ? true, + tex-directory ? "minimal_examples", +}: +# https://nixos.wiki/wiki/TexLive +# https://flyx.org/nix-flakes-latex/ +stdenvNoCC.mkDerivation rec { + pname = "pure-minimalistic-${tex-directory}"; + inherit version; + + src = nix-filter { + root = ./..; + include = [ + # Include the "src" path relative to the root + (nix-filter.lib.matchExt "sty") + (nix-filter.lib.matchExt "bib") + "logos/" + "${tex-directory}/" + ]; + }; + + # phases = ["unpackPhase" "buildPhase" "installPhase"]; + + buildInputs = [ + tex-deps + coreutils + findutils + # cntr is kinda broken. Requires these utils to be available + # in buildinputs + # cntr + # breakpointHook + # bash + ]; + + # TODO: Figure out how to wrap this in a shellchecker and with correct flags + # -pretex="\pdfvariable suppressoptionalinfo 512\relax" \ # lualatex + buildPhase = + '' + export PATH="${lib.makeBinPath buildInputs}"; + mkdir -p .cache/texmf-var + '' + + lib.optionalString (tex-directory != ".") '' + mv ${tex-directory}/* . + '' + + '' + env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \ + SOURCE_DATE_EPOCH=${builtins.toString self.lastModified or 0} \ + latexmk \ + -file-line-error -interaction=nonstopmode \ + -pdf \ + '' + + lib.optionalString use-pdflatex '' + -usepretex='\pdftrailerid{}' \ + '' + + lib.optionalString use-lualatex '' + -lualatex \ + -usepretex='\pdfvariable suppressoptionalinfo 512\relax' \ + '' + + '' + *.tex + ''; + + installPhase = '' + mkdir -p $out + cp *.pdf $out/ + ''; +} diff --git a/scripts/create_pngs.nu b/scripts/create_pngs.nu new file mode 100644 index 0000000..622cf09 --- /dev/null +++ b/scripts/create_pngs.nu @@ -0,0 +1,72 @@ +#!/usr/bin/env nu + +use std assert + +# how is this called? +# in a wrapping bash script (presumably) +# that provides the paths as arguments that use the environment variables +# from $src and $out ? + +# Convert all PDF files in the `src-dir` to png files, +# where each page of the PDF is converted into a file called +# `-.png` +# Can be used for `minimal_examples` +export def "main convert-pdfs-to-pngs" [ + --src-dir: path + --target-dir: path + --density: int = 300 +]: nothing -> nothing { + cd $src_dir + ls *.pdf | get name | each { + |f| + let stem = $f | path parse | $in.stem + let result_path = $"($target_dir)/($stem)-%02d.png" + ^convert -density $density $f $result_path + } + null +} + +export def "main create-montage compare_examples" [ + --src-dir: path + --target-dir: path +] { + let tmp_dir = mktemp -d + + main convert-pdfs-to-pngs --src-dir $src_dir --target-dir $tmp_dir + print (ls $tmp_dir | table) + let dark_ordered_pngs = (glob $"($tmp_dir)/pureminimalistic_example_dark*.png") | zip (glob $"($tmp_dir)/defaultbeamer_example*.png") | flatten + assert (($dark_ordered_pngs | length) > 0) + let light_ordered_pngs = (glob $"($tmp_dir)/pureminimalistic_example_light*.png") | zip (glob $"($tmp_dir)/defaultbeamer_example*.png") | flatten + assert (($light_ordered_pngs | length) > 0) + ^montage ...$dark_ordered_pngs -geometry +4+4 -tile 2x -background gray -colorspace RGB $"($target_dir)/comparison_dark.png" + ^montage ...$light_ordered_pngs -geometry +4+4 -tile 2x -background gray -colorspace RGB $"($target_dir)/comparison_light.png" + + rm -r $tmp_dir +} + +export def "main create-montage multi_lang_examples" [ + --src-dir: path + --target-dir: path +] { + let tmp_dir = mktemp -d + + main convert-pdfs-to-pngs --src-dir $src_dir --target-dir $tmp_dir + let multi_lang_pngs = (glob $"($tmp_dir)/*.png") + assert (($multi_lang_pngs | length) > 0) + ^montage ...$multi_lang_pngs -geometry +4+4 -tile 2x -background gray -colorspace RGB $"($target_dir)/lang_comparison.png" + + rm -r $tmp_dir +} + +export def "main create-montage demo" [ + --src-dir: path + --target-dir: path +] { + let tmp_dir = mktemp -d + main convert-pdfs-to-pngs --src-dir $src_dir --target-dir $tmp_dir + ^montage ...(glob $"($tmp_dir)/*.png") -geometry +10+10 -tile 4x -background gray $"($target_dir)/beamertheme-pure-minimalistic-demo.png" + + rm -r $tmp_dir +} + +export def main [] {}