Render schematic PDFs via Nix

This happens via kiauto and a new Nix build target. The results are not
yet pushed anywhere.
This commit is contained in:
Serge Bazanski 2020-12-13 21:33:43 +01:00
parent 592d58d06d
commit 8a4725f748
4 changed files with 78 additions and 10 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
result

View file

@ -18,6 +18,15 @@ You can use [nix](https://nixos.org/guides/how-nix-works.html) to get KiCAD (and
And then just starting `kicad` from that shell.
## Schematic PDFs
To build schematics PDFs from KiCAD .sch, build the 'build' target from `default.nix`:
$ nix-build -A build
$ ls result/
TODO(#8): automate pushing the results of this somewhere.
## Copyright, licensing, etc.
Unlesss stated otherwise, all original work is Copyright (c) 2020 FM10K-Documentation Contributors, licensed under the Creative Commons CC-BY 4.0 License. See COPYING for more information. For the purposes of attribution, use either `FM10K-Documentation Contributors`, or names available in this repository's git history.

67
default.nix Normal file
View file

@ -0,0 +1,67 @@
let
# Tracking nixos-unstable as of 2020-12-13.
nixpkgsCommit = "e9158eca70ae59e73fae23be5d13d3fa0cfc78b4";
nixpkgsSrc = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsCommit}.tar.gz";
sha256 = "0cnmvnvin9ixzl98fmlm3g17l6w95gifqfb3rfxs55c0wj2ddy53";
};
nixpkgs = import nixpkgsSrc {};
in with nixpkgs; let
pythonPackages = pkgs.python37Packages;
# kiauto is a cursed little Python library to automate KiCAD interaction.
# It uses a virtual X server (via xvfb) to export PDFs, etc.
# I wish we didn't have to do this, but KiCAD just isn't very good sometimes.
kiauto = pythonPackages.buildPythonPackage rec {
pname = "kiauto";
version = "1.5.3";
propagatedBuildInputs = (with pythonPackages; [
kicad xvfbwrapper psutil
]) ++ (with pkgs; [
xdotool xclip
xorg.xset xorg.setxkbmap
kicad-small
]);
src = pythonPackages.fetchPypi {
inherit pname version;
sha256 = "09jr4ym9jq3g8k961169yaqnzhl02vsqs7g3r7wbxlqz4hs1z5yw";
};
# fix kiauto/misc.py to point to the right location of KiCAD libraries on Nix.
patchPhase = ''
sed -i 's,sys_sym_lib_table = .*$,sys_sym_lib_table = ["${kicad-small.libraries.symbols}/share/kicad/template/sym-lib-table"],' kiauto/misc.py
sed -i 's,sys_fp_lib_table = .*$,sys_fp_lib_table = ["${kicad-small.libraries.footprints}/share/kicad/template/fp-lib-table"],' kiauto/misc.py
'';
};
in {
inherit nixpkgs;
# Single build target for everything. This should probably be split up at
# same later point into multiple subdirectories/subfiles/subtargets - but it
# will do for now.
build = stdenv.mkDerivation {
pname = "fm10k-documentation-build";
version = "0.1.0";
nativeBuildInputs = [
kicad-small kiauto
];
buildPhase = ''
mkdir build
cd build
export HOME=$(pwd)/home
mkdir $HOME
eeschema_do export -a ../PE3100G2DQiRM-QX4.sch .
'';
installPhase = ''
mkdir -p $out
cp *pdf $out/
'';
src = ./devices/Silicom/PE3100G2DQiRM-QX4/pcb;
};
}

View file

@ -7,16 +7,7 @@
# $ kicad
#
let
# Tracking nixos-unstable as of 2020-12-13.
nixpkgsCommit = "e9158eca70ae59e73fae23be5d13d3fa0cfc78b4";
nixpkgsSrc = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsCommit}.tar.gz";
sha256 = "0cnmvnvin9ixzl98fmlm3g17l6w95gifqfb3rfxs55c0wj2ddy53";
};
nixpkgs = import nixpkgsSrc {};
in with nixpkgs;
with (import ./default.nix).nixpkgs;
pkgs.mkShell {
buildInputs = with pkgs; [