summaryrefslogtreecommitdiff
path: root/clef/nix/bom.nix
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2024-08-15 04:25:39 -0400
committerNathan Perry <np@nathanperry.dev>2024-08-15 04:25:39 -0400
commitf081aa9e2f243ffe6ea13024e3777626a8243aed (patch)
treec1ec687b1953a7f3e78d667ba09fbb5872917b50 /clef/nix/bom.nix
parent9332cf7c0eac27ed5c00ec19e87d4d76b56f223a (diff)
clef/nix: support generating interactivehtmlbom
Diffstat (limited to 'clef/nix/bom.nix')
-rw-r--r--clef/nix/bom.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/clef/nix/bom.nix b/clef/nix/bom.nix
new file mode 100644
index 0000000..7644939
--- /dev/null
+++ b/clef/nix/bom.nix
@@ -0,0 +1,38 @@
+{
+ runCommand,
+ interactiveHtmlBom,
+
+ nix-filter,
+ lib,
+
+ pcb_path,
+ src,
+
+ boardName ? (lib.removeSuffix ".kicad_pcb" (builtins.baseNameOf pcb_path)),
+ extraArgs ? [],
+}: let
+ sharePath = "share/npry/clef/bom";
+
+in runCommand "${boardName}.bom" {
+ nativeBuildInputs = [
+ interactiveHtmlBom
+ ];
+
+ INTERACTIVE_HTML_BOM_NO_DISPLAY = 1;
+
+ src = nix-filter {
+ root = src;
+
+ include = [
+ (nix-filter.matchExt "kicad_pcb")
+ (nix-filter.matchExt "kicad_pro")
+ ];
+ };
+} ''
+ mkdir -p "$out/${sharePath}"
+
+ generate_interactive_bom \
+ --dest-dir "$out/${sharePath}" \
+ ${lib.concatMapStrings (arg: "${arg} \\n") extraArgs} \
+ "$src/${pcb_path}"
+''