-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathflake.nix
More file actions
113 lines (102 loc) · 2.89 KB
/
flake.nix
File metadata and controls
113 lines (102 loc) · 2.89 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
description = "Nix flake for the pcb CLI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
};
outputs =
{ self, nixpkgs, crane, ... }:
let
lib = nixpkgs.lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs systems;
workspaceCargo = builtins.fromTOML (builtins.readFile ./Cargo.toml);
packageFor =
system:
let
pkgs = import nixpkgs { inherit system; };
craneLib = crane.mkLib pkgs;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
(craneLib.fileset.commonCargoSources ./.)
./crates/pcb/src/fortune.txt
./crates/pcb/src/templates
./crates/pcb-component-gen/templates
./crates/pcb-ipc2581-tools/src/commands/html_template.html.jinja
./crates/pcb-ipc2581-tools/src/commands/style.css
./crates/pcb-layout/src/scripts
./docs/pages
./stdlib
];
};
commonArgs = {
pname = "pcb";
version = workspaceCargo.workspace.package.version;
inherit src;
strictDeps = true;
doCheck = false;
cargoExtraArgs = "-p pcb";
nativeBuildInputs = with pkgs; [
makeWrapper
pkg-config
];
buildInputs = with pkgs; [
python312
python312Packages.kicad
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
postFixup = ''
wrapProgram $out/bin/pcb \
--set KICAD_PYTHON_SITE_PACKAGES "${pkgs.python312Packages.kicad}/${pkgs.python312.sitePackages}" \
--set KICAD_PYTHON_INTERPRETER "${pkgs.python312}/bin/python"
'';
meta = with lib; {
description = "CLI for circuit board design";
homepage = "https://github.com/diodeinc/pcb";
license = licenses.mit;
mainProgram = "pcb";
platforms = platforms.unix;
};
}
);
in
{
packages = forAllSystems (
system:
let
pcb = packageFor system;
in
{
default = pcb;
inherit pcb;
}
);
apps = forAllSystems (
system:
let
pcb = self.packages.${system}.pcb;
in
{
default = {
type = "app";
program = "${pcb}/bin/pcb";
};
pcb = {
type = "app";
program = "${pcb}/bin/pcb";
};
}
);
};
}