From b5eba29877c160458e51eaa584db359ea901d5ec Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Wed, 14 Aug 2024 22:08:01 -0400 Subject: nix: use inkscape to trim svg padding --- clef/nix/svg.nix | 10 ++++++++++ flake.lock | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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" }, -- cgit v1.3.1