clef

automatic, configurable kicad project outputs with nix

2024-08-14

clef started as a KiCad project template repo, but I just spent a day or two setting it up to support processing KiCad projects into 3d models, schematics, SVGs, and fabrication files through Nix, which builds this blog. That means that as part of the deployment process for this blog, the version of the ocularium repo that I've pinned is automatically built, meaning the content on that page is always up-to-date.

$ nix build .# && nix run nixpkgs#tree result
result
└── share
    └── npry
        └── ocularium
            ├── fab
               ├── bom.csv
               ├── gerbers.zip
               └── pos.csv
            ├── model
               ├── okm.glb
               └── okm.step
            ├── schematic
               ├── schematic.pdf
               └── svg
                   ├── IO.svg
                   ├── MCU.svg
                   ├── Power.svg
                   ├── root.svg
                   └── Sensors.svg
            └── svg
                ├── back.mirror.svg
                ├── back.svg
                ├── front.mirror.svg
                ├── front.svg
                ├── in1.mirror.svg
                ├── in1.svg
                ├── in2.mirror.svg
                └── in2.svg

8 directories, 19 files

board svgs

I've just realized the board SVGs exported by KiCad are actual size (they embed board dimensions), so when rendered on a webpage they are by default the real size of the board. I added an inkscape step to .svgs to support trimming off the substantial whitespace KiCad includes so they're easier to embed (inkscape preserves the size metadata, including adjusting for its trimmed size).