diff options
Diffstat (limited to 'nix/svg.nix')
| -rw-r--r-- | nix/svg.nix | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/nix/svg.nix b/nix/svg.nix new file mode 100644 index 0000000..3d93ecc --- /dev/null +++ b/nix/svg.nix @@ -0,0 +1,64 @@ +{ + runCommand, + kicad, + nix-filter, + + panel, +}: runCommand "ocularium.svg" { + nativeBuildInputs = [ + kicad + ]; + + src = nix-filter { + root = ./..; + + exclude = [ + "nix" + ".gitignore" + "flake.nix" + "flake.lock" + ".envrc" + "kikit" + "models" + ]; + }; + + allowedRequisites = []; +} '' + set -e + + export HOME=$(mktemp -d) + + mkdir -p $out/share/npry/ocularium/svg + mkdir -p $out/share/npry/ocularium/panel/svg + + mksvg() { + local infile=$1 + local layers=$2 + local outfile=$3 + + kicad-cli pcb export svg \ + "$infile.kicad_pcb" \ + -l "$layers" \ + -o $outfile.svg \ + --page-size-mode 2 \ + --exclude-drawing-sheet + } + + readonly okm="$src/okm" + readonly panel="${panel}/share/npry/ocularium/panel" + + cd $out/share/npry/ocularium/svg + + mksvg "$okm" "F.Cu,F.Silkscreen,Edge.Cuts" front + mksvg "$okm" "B.Cu,B.Silkscreen,Edge.Cuts" back + mksvg "$okm" "In1.Cu,Edge.Cuts" in1 + mksvg "$okm" "In2.Cu,Edge.Cuts" in2 + + cd ../panel/svg + + mksvg "$panel" "F.Cu,F.Silkscreen,Edge.Cuts" front + mksvg "$panel" "B.Cu,B.Silkscreen,Edge.Cuts" back + mksvg "$panel" "In1.Cu,Edge.Cuts" in1 + mksvg "$panel" "In2.Cu,Edge.Cuts" in2 +'' |
