168 lines
5.8 KiB
Nix
168 lines
5.8 KiB
Nix
{
|
|
flake-parts-lib,
|
|
inputs,
|
|
...
|
|
}: {
|
|
flake = {
|
|
templates = {
|
|
build123d = {
|
|
path = ./template;
|
|
description = "A python flake with a build132d parametric cad setup";
|
|
};
|
|
};
|
|
|
|
flakeModules.build123d = {
|
|
imports = [
|
|
inputs.treefmt-nix.flakeModule
|
|
];
|
|
|
|
options.perSystem = flake-parts-lib.mkPerSystemOption ({
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
self',
|
|
...
|
|
}: let
|
|
cfg = config.krantz.build123d;
|
|
|
|
python = pkgs.python3.override {
|
|
self = python;
|
|
packageOverrides = pyfinal: pyprev: {
|
|
build123d = pyfinal.callPackage ./packages/build123d.nix {};
|
|
cadquery-ocp = pyfinal.callPackage ./packages/cadquery-ocp.nix {};
|
|
cadquery-ocp-proxy = pyfinal.callPackage ./packages/cadquery-ocp-proxy.nix {};
|
|
ocp-gordon = pyfinal.callPackage ./packages/ocp-gordon.nix {};
|
|
ocpsvg = pyfinal.callPackage ./packages/ocpsvg.nix {};
|
|
trianglesolver = pyfinal.callPackage ./packages/trianglesolver.nix {};
|
|
};
|
|
};
|
|
in {
|
|
options.krantz.build123d = {
|
|
enable = lib.mkEnableOption "building a cargo project with crane";
|
|
|
|
# src = lib.mkOption {
|
|
# description = "The path to the root of the crate.";
|
|
# type = lib.types.path;
|
|
# example = lib.literalExpression "./.";
|
|
# };
|
|
# srcFiltered = lib.mkOption {
|
|
# description = "A path to the filtered directory of the root of the crate.";
|
|
# type = lib.types.path;
|
|
# default = craneLib.cleanCargoSource cfg.src;
|
|
# defaultText = lib.literalExpression "config.krantz.rust.craneLib cfg.src";
|
|
# example = lib.literalExpression "./.";
|
|
# };
|
|
#
|
|
# runtimeDeps = lib.mkOption {
|
|
# description = "Packages needed for the app to run.";
|
|
# type = lib.types.listOf lib.types.package;
|
|
# default = [];
|
|
# example = with pkgs; [
|
|
# openssl
|
|
# ];
|
|
# };
|
|
# buildDeps = lib.mkOption {
|
|
# description = "Packages needed for the app to build.";
|
|
# type = lib.types.listOf lib.types.package;
|
|
# default = [];
|
|
# example = with pkgs; [
|
|
# pkg-config
|
|
# rustPlatform.bindgenHook
|
|
# ];
|
|
# };
|
|
# devDeps = lib.mkOption {
|
|
# description = "Packages to include only in the devShell.";
|
|
# type = lib.types.listOf lib.types.package;
|
|
# default = with pkgs; [
|
|
# rust-analyzer
|
|
# ];
|
|
# };
|
|
#
|
|
# devShell = {
|
|
# enable = lib.mkEnableOption "a rust development environment" // {default = true;};
|
|
#
|
|
# name = lib.mkOption {
|
|
# description = "The name of the attribute in devShells to configure";
|
|
# type = lib.types.str;
|
|
# default = "default";
|
|
# example = "rust";
|
|
# };
|
|
#
|
|
# extraAttrs = lib.mkOption {
|
|
# description = "Extra attributes to merge into the devshell. See https://crane.dev/API.html#cranelibdevshell";
|
|
# type = lib.types.attrs;
|
|
# default = {};
|
|
# example = {
|
|
# shellHook = ''
|
|
# export DEBUG=1
|
|
# '';
|
|
# };
|
|
# };
|
|
# };
|
|
#
|
|
# package = {
|
|
# enable = lib.mkEnableOption "the compiled cargo project" // {default = true;};
|
|
#
|
|
# name = lib.mkOption {
|
|
# description = "The name of the attribute in packages to configure";
|
|
# type = lib.types.str;
|
|
# default = "default";
|
|
# example = "lib";
|
|
# };
|
|
#
|
|
# extraAttrs = lib.mkOption {
|
|
# description = "Extra attributes to merge into the package. See https://crane.dev/API.html#cranelibbuildpackage";
|
|
# type = lib.types.attrs;
|
|
# default = {};
|
|
# example = {
|
|
# doCheck = false;
|
|
# };
|
|
# };
|
|
# };
|
|
#
|
|
# craneLib = lib.mkOption {
|
|
# description = "The crane lib instance this module is using. Useful for overriding options";
|
|
# default = craneLib;
|
|
# defaultText = lib.literalExpression "crane.mkLib pkgs";
|
|
# readOnly = true;
|
|
# };
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# Dev Shell that lets you enter an environment with all the necessary utilites
|
|
# Available through 'nix develop'
|
|
# Also can be activated automatically if direnv is installed on the system with 'direnv allow'
|
|
# devShells.${cfg.devShell.name} = lib.mkIf cfg.devShell.enable (pkgs.mkShell {
|
|
# # extra tooling dependencies
|
|
# packages = cfg.devDeps;
|
|
#
|
|
# inputsFrom = [self'.packages.${cfg.package.name}];
|
|
# }
|
|
# // cfg.devShell.extraAttrs);
|
|
devShells.default = pkgs.mkShell {
|
|
# extra tooling dependencies
|
|
packages = [
|
|
(python.withPackages (p:
|
|
with p; [
|
|
build123d
|
|
]))
|
|
];
|
|
};
|
|
|
|
# Formatter for nix files, available through 'nix fmt'
|
|
treefmt = {
|
|
programs.alejandra.enable = lib.mkDefault true;
|
|
};
|
|
|
|
# Your custom packages
|
|
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
|
# packages.${cfg.package.name} = lib.mkIf cfg.package.enable ( {
|
|
# inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
|
# }
|
|
# // cfg.package.extraAttrs);
|
|
};
|
|
});
|
|
};
|
|
};
|
|
}
|