add flake to provide environnement
added flake.nix to provide a build and dev environnement to bootstrap a venv with presenterm and weasyprint easily added a package output to flake.nix to build all the posts. the build process use a python script for easier extensibility
This commit is contained in:
parent
aa7fec3b1b
commit
aa6bfb373c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
result/
|
||||
25
flake.lock
generated
Normal file
25
flake.lock
generated
Normal file
@ -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
|
||||
}
|
||||
84
flake.nix
Normal file
84
flake.nix
Normal file
@ -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
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
3
src/Makefile
Normal file
3
src/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
install:
|
||||
mkdir -p ${out}
|
||||
cp output/* ${out}/
|
||||
11
src/configs/presenterm.yaml
Normal file
11
src/configs/presenterm.yaml
Normal file
@ -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
|
||||
|
||||
BIN
src/output/nginx.pdf
Normal file
BIN
src/output/nginx.pdf
Normal file
Binary file not shown.
BIN
src/output/vue.pdf
Normal file
BIN
src/output/vue.pdf
Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 743 KiB After Width: | Height: | Size: 743 KiB |
BIN
src/posts/shoblog/nginx/nginx.pdf
Normal file
BIN
src/posts/shoblog/nginx/nginx.pdf
Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
14
src/scripts/build.py
Normal file
14
src/scripts/build.py
Normal file
@ -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')
|
||||
Loading…
x
Reference in New Issue
Block a user