aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2024-08-14 22:08:01 -0400
committerNathan Perry <np@nathanperry.dev>2024-08-14 22:08:01 -0400
commitb5eba29877c160458e51eaa584db359ea901d5ec (patch)
tree3dc24f6d0f035e5f72486841d5a834f306c0c592
parent3a5c8b37d54150c93b1322ae7cc767d0a314b3d9 (diff)
nix: use inkscape to trim svg padding
-rw-r--r--clef/nix/svg.nix10
-rw-r--r--flake.lock2
2 files changed, 11 insertions, 1 deletions
diff --git a/clef/nix/svg.nix b/clef/nix/svg.nix
index fc1a404..c93ba87 100644
--- a/clef/nix/svg.nix
+++ b/clef/nix/svg.nix
@@ -1,6 +1,7 @@
{
runCommand,
kicad,
+ inkscape,
nix-filter,
lib,
@@ -20,6 +21,7 @@
in runCommand "${boardName}.svg" {
nativeBuildInputs = [
kicad
+ inkscape
];
src = nix-filter {
@@ -55,6 +57,10 @@ in runCommand "${boardName}.svg" {
--page-size-mode 2 \
--exclude-drawing-sheet
+ inkscape --actions 'select-all;fit-canvas-to-selection' \
+ -o "$outfile.trim.svg" \
+ "$outfile.svg"
+
${if withMirrors then ''
kicad-cli pcb export svg \
"$infile" \
@@ -63,6 +69,10 @@ in runCommand "${boardName}.svg" {
-o "$outfile.mirror.svg" \
--page-size-mode 2 \
--exclude-drawing-sheet
+
+ inkscape --actions 'select-all;fit-canvas-to-selection' \
+ -o "$outfile.mirror.trim.svg" \
+ "$outfile.mirror.svg"
'' else ""}
}
diff --git a/flake.lock b/flake.lock
index c395ed8..ac5415a 100644
--- a/flake.lock
+++ b/flake.lock
@@ -30,7 +30,7 @@
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-LNZY8xQ0ooccTQj3z8cOcKOimnlOpYumZRCflzHMpvI=",
+ "narHash": "sha256-PhcMyHR8X6UyeV6hQzw2ykARMcHbRJJFJ1REuk+jq2E=",
"path": "./clef",
"type": "path"
},