- Add complete config.txt settings with u-boot boot lines + spi=on - Override sdImage.populateFirmwareCommands to use configtxt module output - Mount firmware partition and add activation script to sync config.txt - Load spi_bcm2835 and bcm2835_gpiomem kernel modules - Add udev rule for gpiomem subsystem (not just gpio) - Relax ProtectKernelTunables so service can access GPIO - Update turny flake input to rppal-based CS pin fix
161 lines
3.5 KiB
Nix
161 lines
3.5 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
}:
|
|
let
|
|
stylesheet = pkgs.writeText "md2pdf-style.css" ''
|
|
body {
|
|
font-family: "Noto Sans", sans-serif;
|
|
font-size: 11px;
|
|
max-width: 100%;
|
|
margin: 0;
|
|
padding: 15px;
|
|
line-height: 1.4;
|
|
}
|
|
h1 {
|
|
font-size: 22px;
|
|
border-bottom: 2px solid #333;
|
|
padding-bottom: 5px;
|
|
break-after: avoid;
|
|
}
|
|
h2 {
|
|
font-size: 18px;
|
|
margin-top: 25px;
|
|
border-bottom: 1px solid #ccc;
|
|
padding-bottom: 3px;
|
|
break-after: avoid;
|
|
}
|
|
h3 {
|
|
font-size: 14px;
|
|
margin-top: 15px;
|
|
break-after: avoid;
|
|
}
|
|
table {
|
|
border-collapse: collapse;
|
|
width: 100%;
|
|
font-size: 10px;
|
|
margin: 10px 0;
|
|
}
|
|
th {
|
|
background: #f0f0f0;
|
|
border: 1px solid #ccc;
|
|
padding: 4px 6px;
|
|
text-align: left;
|
|
break-after: avoid;
|
|
break-inside: avoid;
|
|
}
|
|
td {
|
|
border: 1px solid #ccc;
|
|
padding: 4px 6px;
|
|
vertical-align: top;
|
|
break-inside: avoid;
|
|
}
|
|
tr {
|
|
break-inside: avoid;
|
|
break-after: auto;
|
|
}
|
|
code {
|
|
background: #f5f5f5;
|
|
padding: 1px 3px;
|
|
border-radius: 2px;
|
|
font-family: "Noto Sans Mono", monospace;
|
|
font-size: 10px;
|
|
}
|
|
pre {
|
|
background: #f5f5f5;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
overflow-x: auto;
|
|
font-size: 10px;
|
|
}
|
|
pre code {
|
|
background: none;
|
|
padding: 0;
|
|
}
|
|
blockquote {
|
|
border-left: 3px solid #ccc;
|
|
margin-left: 0;
|
|
padding-left: 10px;
|
|
color: #555;
|
|
}
|
|
img {
|
|
max-width: 100%;
|
|
height: auto;
|
|
border: 1px solid #ddd;
|
|
margin: 5px 0;
|
|
break-inside: avoid;
|
|
}
|
|
em {
|
|
color: #666;
|
|
}
|
|
a {
|
|
color: #0066cc;
|
|
}
|
|
'';
|
|
|
|
md-to-pdf = pkgs.buildNpmPackage {
|
|
pname = "md-to-pdf";
|
|
version = "5.2.5";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "simonhaenisch";
|
|
repo = "md-to-pdf";
|
|
rev = "v5.2.5";
|
|
hash = "sha256-6Zr4jidQ6cX2t6jKFqEnCSqvRtw4gZkqDKdv9SIyDC4=";
|
|
};
|
|
|
|
npmDepsHash = "sha256-AGn8g/nbkvWi4o6ENCnt7VexjfBIoDz+tl9eYvy+bao=";
|
|
|
|
# canvas is an optional native dependency that fails to build in nix;
|
|
# md-to-pdf works fine without it (puppeteer is used for PDF generation)
|
|
npmFlags = [ "--ignore-scripts" ];
|
|
|
|
postInstall = ''
|
|
rm -rf $out/lib/node_modules/md-to-pdf/node_modules/canvas
|
|
'';
|
|
};
|
|
in
|
|
pkgs.stdenv.mkDerivation {
|
|
pname = "md2pdf";
|
|
version = "1.0.0";
|
|
|
|
src = ./.;
|
|
|
|
dontBuild = true;
|
|
|
|
nativeBuildInputs = [ ];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin $out/share/md2pdf
|
|
|
|
cp ${stylesheet} $out/share/md2pdf/style.css
|
|
|
|
cat > $out/bin/md2pdf << 'WRAPPER'
|
|
#!/bin/sh
|
|
export PUPPETEER_EXECUTABLE_PATH="@chromium@/bin/chromium"
|
|
export PATH="@chromium@/bin''${PATH:+:''${PATH}}"
|
|
exec "@md-to-pdf@/bin/md-to-pdf" \
|
|
--stylesheet "@stylesheet@" \
|
|
--pdf-options '{"format":"A4","margin":{"top":"10mm","bottom":"10mm","left":"12mm","right":"12mm"},"printBackground":true}' \
|
|
"$@"
|
|
WRAPPER
|
|
|
|
substituteInPlace $out/bin/md2pdf \
|
|
--replace-fail "@chromium@" "${pkgs.chromium}" \
|
|
--replace-fail "@md-to-pdf@" "${md-to-pdf}" \
|
|
--replace-fail "@stylesheet@" "$out/share/md2pdf/style.css"
|
|
|
|
chmod +x $out/bin/md2pdf
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = {
|
|
description = "Convert Markdown to PDF with Noto Sans styling and tight margins";
|
|
mainProgram = "md2pdf";
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
}
|