aboutsummaryrefslogtreecommitdiff
path: root/clef/nix/default.nix
blob: 4438bbe1e09a0a2e4cd5d5f4852aec637df2837a (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
53
54
55
56
57
58
{
  pkgs,

  src,
  main_pcb,
  main_sch,

  name,
  outPath ? "share/npry/clef",
  layers ? 2,

  # set to a list of arguments to be passed to `kikit panelize -p`
  panelizeConfigs ? null,
}: let
  pcb_path = main_pcb;
  sch_path = main_sch;

  pcb_args = {
    inherit pcb_path src;
  };

  panelSrc = if panelizeConfigs != null then pkgs.callPackage ./panel.nix (pcb_args // { inherit panelizeConfigs; }) else null;

  panel = if panelizeConfigs != null then
    pkgs.callPackage ./. {
      src = "${panelSrc}/share/npry/clef/panel";
      main_pcb = "panel.kicad_pcb";

      name = "${name}.sub.panel";
      outPath = "${outPath}/panel";

      inherit main_sch layers;
    }
  else null;

  svg = pkgs.callPackage ./svg.nix (pcb_args // { nLayer = layers; });
  model = pkgs.callPackage ./model.nix pcb_args;

  fabrication = pkgs.callPackage ./fabrication.nix (pcb_args // {
    inherit sch_path;
  });

  schematic = pkgs.callPackage ./schematic.nix {
    inherit sch_path src;
  };

in pkgs.callPackage ./board.nix {
  inherit
    svg
    model
    fabrication
    schematic
    name
    outPath
    panel
    panelSrc
  ;
}