aboutsummaryrefslogtreecommitdiff
path: root/nix/svg.nix
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2024-08-14 01:34:16 -0400
committerNathan Perry <np@nathanperry.dev>2024-08-14 03:29:44 -0400
commita330a1fad3c1ccdd926297747c03fe95bcaa6587 (patch)
treea8d7ccdfd0ac1d420b4346ad9c0badaf2d31868d /nix/svg.nix
parent7f5e8f7d7d467f6dd3321cfa7eb276396a21dc69 (diff)
nix: migrate functionality to clef
Diffstat (limited to 'nix/svg.nix')
-rw-r--r--nix/svg.nix82
1 files changed, 0 insertions, 82 deletions
diff --git a/nix/svg.nix b/nix/svg.nix
deleted file mode 100644
index fc1a404..0000000
--- a/nix/svg.nix
+++ /dev/null
@@ -1,82 +0,0 @@
-{
- runCommand,
- kicad,
-
- nix-filter,
- lib,
-
- pcb_path,
- src,
-
- withSilk ? true,
- withEdgeCuts ? true,
- withMirrors ? true,
- nLayer ? 2,
-
- boardName ? (lib.removeSuffix ".kicad_pcb" (builtins.baseNameOf pcb_path)),
-}: let
- sharePath = "share/npry/clef/svg";
-
-in runCommand "${boardName}.svg" {
- nativeBuildInputs = [
- kicad
- ];
-
- src = nix-filter {
- root = src;
-
- include = [
- (nix-filter.matchExt "kicad_pcb")
- ];
- };
-
- nInnerLayer = if nLayer < 2 then 0 else nLayer - 2;
-
- allowedRequisites = [];
-} ''
- set -e
-
- export HOME=$(mktemp -d)
-
- echo "board: '${boardName}'" >&2
-
- mkdir -p $out/${sharePath}
- cd "$out/${sharePath}"
-
- mksvg() {
- local infile=$1
- local layers=$2
- local outfile=$3
-
- kicad-cli pcb export svg \
- "$infile" \
- -l "$layers" \
- -o "$outfile.svg" \
- --page-size-mode 2 \
- --exclude-drawing-sheet
-
- ${if withMirrors then ''
- kicad-cli pcb export svg \
- "$infile" \
- -m \
- -l "$layers" \
- -o "$outfile.mirror.svg" \
- --page-size-mode 2 \
- --exclude-drawing-sheet
- '' else ""}
- }
-
- mksvg "$src/${pcb_path}" \
- "F.Cu,${if withSilk then "F.Silkscreen," else ""}${if withEdgeCuts then "Edge.Cuts," else ""}" \
- front
-
- mksvg "$src/${pcb_path}" \
- "B.Cu,${if withSilk then "B.Silkscreen," else ""}${if withEdgeCuts then "Edge.Cuts," else ""}" \
- back
-
- for i in $(seq 1 $nInnerLayer); do
- mksvg "$src/${pcb_path}" \
- "In$i.Cu,${if withEdgeCuts then "Edge.Cuts," else ""}" \
- "in$i"
- done
-''