diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cd791b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..de80f7b --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1757347588, + "narHash": "sha256-tLdkkC6XnsY9EOZW9TlpesTclELy8W7lL2ClL+nma8o=", + "rev": "b599843bad24621dcaa5ab60dac98f9b0eb1cabe", + "revCount": 858212, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.858212%2Brev-b599843bad24621dcaa5ab60dac98f9b0eb1cabe/01992e5d-548e-7231-8669-92a393e208fa/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a04f9f7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,84 @@ +{ + description = "An empty flake template that you can adapt to your own environment"; + + # Flake inputs + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; + + # Flake outputs + outputs = + inputs: + let + # The systems supported for this flake + supportedSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + "x86_64-darwin" # 64-bit Intel macOS + "aarch64-darwin" # 64-bit ARM macOS + ]; + + # Helper to provide system-specific attributes + forEachSupportedSystem = + f: + inputs.nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import inputs.nixpkgs { inherit system; }; + } + ); + in + { + devShells = forEachSupportedSystem ( + { pkgs }: { + default = pkgs.mkShell { + # The Nix packages provided in the environment + # Add any you need here + packages = with pkgs; [ + presenterm + python313Packages.weasyprint + ]; + + # Set any environment variables for your dev shell + env = { }; + + # Add any shell logic you want executed any time the environment is activated + shellHook = ''''; + }; + } + ); + packages = forEachSupportedSystem ( + { pkgs }: { + default = pkgs.stdenv.mkDerivation { + inherit (pkgs) system; + name = "linkedin-shoblog-posts"; + src = ./src; + buildInputs = with pkgs; [ + presenterm + python313Packages.weasyprint + ]; + buildPhase = let + font_dir = "${pkgs.nerd-fonts.jetbrains-mono}/share/fonts/truetype/NerdFonts/JetBrainsMono/"; + config = pkgs.writeTextFile { + name = "presenterm.conf"; + text = '' + export: + dimensions: + columns: 108 + rows: 85 + pdf: + fonts: + normal: ${font_dir}/JetBrainsMonoNerdFont-Regular.ttf + italic: ${font_dir}/JetBrainsMonoNerdFont-Italic.ttf + bold: ${font_dir}/JetBrainsMonoNerdFont-Bold.ttf + bold_italic: ${font_dir}/JetBrainsMonoNerdFont-BoldItalic.ttf + ''; + }; + in + '' + export PRES_CONFIG=${config} + python scripts/build.py + ''; + }; + } + ); + }; +} diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..d17d652 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,3 @@ +install: + mkdir -p ${out} + cp output/* ${out}/ diff --git a/src/configs/presenterm.yaml b/src/configs/presenterm.yaml new file mode 100644 index 0000000..77d73b3 --- /dev/null +++ b/src/configs/presenterm.yaml @@ -0,0 +1,11 @@ +export: + dimensions: + columns: 108 + rows: 85 + pdf: + fonts: + normal: /usr/share/fonts/truetype/tlwg/TlwgMono.ttf + italic: /usr/share/fonts/truetype/tlwg/TlwgMono-Oblique.ttf + bold: /usr/share/fonts/truetype/tlwg/TlwgMono-Bold.ttf + bold_italic: /usr/share/fonts/truetype/tlwg/TlwgMono-BoldOblique.ttf + diff --git a/src/output/nginx.pdf b/src/output/nginx.pdf new file mode 100644 index 0000000..fc4731f Binary files /dev/null and b/src/output/nginx.pdf differ diff --git a/src/output/vue.pdf b/src/output/vue.pdf new file mode 100644 index 0000000..a8da58c Binary files /dev/null and b/src/output/vue.pdf differ diff --git a/shoblog/nginx/cover.jpg b/src/posts/shoblog/nginx/cover.jpg similarity index 100% rename from shoblog/nginx/cover.jpg rename to src/posts/shoblog/nginx/cover.jpg diff --git a/shoblog/nginx/nginx.md b/src/posts/shoblog/nginx/nginx.md similarity index 100% rename from shoblog/nginx/nginx.md rename to src/posts/shoblog/nginx/nginx.md diff --git a/shoblog/nginx/nginx.nix b/src/posts/shoblog/nginx/nginx.nix similarity index 100% rename from shoblog/nginx/nginx.nix rename to src/posts/shoblog/nginx/nginx.nix diff --git a/src/posts/shoblog/nginx/nginx.pdf b/src/posts/shoblog/nginx/nginx.pdf new file mode 100644 index 0000000..ebe588a Binary files /dev/null and b/src/posts/shoblog/nginx/nginx.pdf differ diff --git a/shoblog/nginx/nix_nginx.png b/src/posts/shoblog/nginx/nix_nginx.png similarity index 100% rename from shoblog/nginx/nix_nginx.png rename to src/posts/shoblog/nginx/nix_nginx.png diff --git a/shoblog/nginx/terminal-ls.png b/src/posts/shoblog/nginx/terminal-ls.png similarity index 100% rename from shoblog/nginx/terminal-ls.png rename to src/posts/shoblog/nginx/terminal-ls.png diff --git a/shoblog/vuejs/shoblog_code.nix b/src/posts/shoblog/vue/shoblog_code.nix similarity index 100% rename from shoblog/vuejs/shoblog_code.nix rename to src/posts/shoblog/vue/shoblog_code.nix diff --git a/shoblog/vuejs/vue.md b/src/posts/shoblog/vue/vue.md similarity index 100% rename from shoblog/vuejs/vue.md rename to src/posts/shoblog/vue/vue.md diff --git a/src/scripts/build.py b/src/scripts/build.py new file mode 100644 index 0000000..dd0a42e --- /dev/null +++ b/src/scripts/build.py @@ -0,0 +1,14 @@ +import os +from pathlib import Path +from subprocess import run + +posts = [post for topic in Path("./posts").iterdir() for post in topic.iterdir()] + +config = Path(os.environ.get("PRES_CONFIG", "./configs/presenterm.yaml")) + +out_dir = Path('./output') +out_dir.exists() or out_dir.mkdir() + +for post_dir in posts: + run_result = run([f"presenterm -e --config-file {config} {post_dir / f'{post_dir.name}.md'}"], shell = True) + (post_dir / f'{post_dir.name}.pdf').replace(out_dir / f'{post_dir.name}.pdf')