turny: fix SPI/GPIO config for newer kernels
Build Images / build (push) Successful in 1m40s
Check / check (push) Failing after 3m10s

- 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
This commit is contained in:
Joakim Repomaa
2026-07-05 02:01:53 +03:00
parent 0e664c51f5
commit ee22668d3e
65 changed files with 1336 additions and 500 deletions
+6
View File
@@ -0,0 +1,6 @@
{
util,
lib,
...
}:
util.package { inherit lib; }
+80
View File
@@ -0,0 +1,80 @@
{
pkgs,
lib,
}:
let
version = "4.9.9";
src = pkgs.fetchFromGitHub {
owner = "kreuzberg-dev";
repo = "kreuzberg";
rev = "v${version}";
hash = "sha256-eu0qjyxoRiDLHsBLPPPAqb/DKVaPzqgP/4hHPjgOBoM=";
};
in
pkgs.rustPlatform.buildRustPackage {
pname = "kreuzberg-cli";
inherit version src;
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
inherit src;
hash = "sha256-j1tmjQ7KQQAMz3QxhQGTGracMqqdcaX/+74lpUfU/kE=";
};
buildFeatures = [ "all" ];
doCheck = false;
nativeBuildInputs = [
pkgs.cmake
pkgs.makeWrapper
pkgs.pkg-config
];
buildInputs = [
pkgs.pdfium-binaries
pkgs.openssl
pkgs.onnxruntime
pkgs.tesseract
pkgs.leptonica
];
dontUseCmakeConfigure = true;
env = {
KREUZBERG_PDFIUM_PREBUILT = pkgs.pdfium-binaries;
ORT_LIB_PATH = "${pkgs.onnxruntime}/lib";
ORT_PREFER_DYNAMIC_LINK = "1";
};
postPatch = ''
substituteInPlace crates/kreuzberg/Cargo.toml \
--replace 'kreuzberg-tesseract = { path = "../kreuzberg-tesseract", version = "4.9.9", optional = true }' \
'kreuzberg-tesseract = { path = "../kreuzberg-tesseract", version = "4.9.9", optional = true, default-features = false, features = ["dynamic-linking"] }'
for f in crates/kreuzberg-tesseract/src/*.rs; do
substituteInPlace "$f" \
--replace 'any(feature = "build-tesseract", feature = "build-tesseract-wasm")' \
'any(feature = "build-tesseract", feature = "build-tesseract-wasm", feature = "dynamic-linking")'
done
'';
postFixup = ''
wrapProgram $out/bin/kreuzberg \
--prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [
pkgs.tesseract
pkgs.onnxruntime
]
} \
--set TESSDATA_PREFIX ${pkgs.tesseract}/share
ln -s kreuzberg $out/bin/kreuzberg-cli
'';
meta = {
description = "High-performance document intelligence CLI with a Rust core";
homepage = "https://github.com/kreuzberg-dev/kreuzberg";
license = lib.licenses.unfree;
platforms = [ "x86_64-linux" ];
mainProgram = "kreuzberg";
};
}
+6
View File
@@ -0,0 +1,6 @@
{
util,
lib,
...
}:
util.package { inherit lib; }
+160
View File
@@ -0,0 +1,160 @@
{
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;
};
}