Files
diodeinc__pcb/flake.nix
Martin Charles 926864652c add nix flake (#51)
* add nix flake

nix profile install nix profile install github:diodeinc/pcb

kicad isn't packaged here yet but can deal with that later

used crane as there is a bug in nixpkgs rust https://discourse.nixos.org/t/rust-with-git-deps-symbolic-link-error-to-cargo-vendor-dep/28841 and naserk had some issue as well. crane isn't ideal because it doesn't cache properly but now it one click installs so whatever

* allow external buildifier

* fix linux compilation

next up package kicad in a sane way

* fmt

* apply suggestions
2025-08-04 17:33:39 -04:00

80 lines
1.6 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
crane,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
craneLib = crane.mkLib pkgs;
src = pkgs.lib.cleanSourceWith {
src = lib.cleanSource ./.;
filter = (
orig_path: type:
pkgs.lib.hasSuffix ".py" (baseNameOf (toString orig_path))
|| (craneLib.filterCargoSources orig_path type)
);
name = "pcb-source";
};
commonArgs = {
pname = "pcb";
inherit src;
strictDeps = true;
doCheck = false;
nativeBuildInputs = [
pkgs.pkg-config
pkgs.openssl.dev
];
buildInputs = [
pkgs.pkg-config
pkgs.openssl
];
BUILDIFIER_BIN = "${pkgs.bazel-buildtools}/bin/buildifier";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
pcb = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
doCheck = false;
}
);
in
{
packages = {
default = pcb;
};
apps = {
default = flake-utils.lib.mkApp {
drv = pcb;
};
};
}
);
}