summary refs log tree commit diff
path: root/pkgs/applications/science/electronics/kicad/addons/kikit.nix
blob: 6e5fc5ad967816dc114fb0f3fbe0ca10da38e5aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# For building the multiple addons that are in the kikit repo.
{ stdenv
, bc
, kikit
, zip
, python3
, addonName
, addonPath
}:
let
  # This python is only used when building the package, it's not the python
  # environment that will ultimately run the code packaged here. The python env defined
  # in KiCad will import the python code packaged here when KiCad starts up.
  python = python3.withPackages (ps: with ps; [ click ]);
  kikit-module = python3.pkgs.toPythonModule (kikit.override { inherit python3; });

  # The following different addons can be built from the same source.
  targetSpecs = {
    "kikit" = {
      makeTarget = "pcm-kikit";
      resultZip = "pcm-kikit.zip";
      description = "KiCad plugin and a CLI tool to automate several tasks in a standard KiCad workflow";
    };
    "kikit-library" = {
      makeTarget = "pcm-lib";
      resultZip = "pcm-kikit-lib.zip";
      description = "KiKit uses these symbols and footprints to annotate your boards (e.g., to place a tab in a panel).";
    };
  };
  targetSpec = targetSpecs.${addonName};
in
stdenv.mkDerivation {
  name = "kicadaddon-${addonName}";
  inherit (kikit-module) src version;

  nativeBuildInputs = [ python bc zip ];
  propagatedBuildInputs = [ kikit-module ];

  buildPhase = ''
    patchShebangs scripts/setJson.py
    make ${targetSpec.makeTarget}
  '';

  installPhase = ''
    mkdir $out
    mv build/${targetSpec.resultZip} $out/${addonPath}
  '';

  meta = kikit-module.meta // {
    description = targetSpec.description;
  };
}