{
config,
flake-parts-lib,
lib,
...
}:
let
useGitHooks = config.polyphony.gitHooks.enable;
useRust = config.polyphony.rust.enable;
useTreefmt = config.polyphony.treefmt.enable;
in
{
options.perSystem =
let
inherit (lib)
literalExpression
mkEnableOption
mkIf
mkOption
;
inherit (lib.types) listOf package;
in
flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
let
cfg = config.polyphony.devshell;
in
{
options.polyphony.devshell = {
enable =
(mkEnableOption "creation of a development shell, with required package for local development")
// {
default = true;
example = false;
};
extraPackages = mkOption {
type = listOf package;
default = [ ];
example = literalExpression "[ pkgs.hello ]";
description = ''
A list of extra packages to add to the development shell.
'';
};
};
config = mkIf cfg.enable {
devShells.default = pkgs.mkShell (
{
name = "devshell";
packages =
(with pkgs; [
nix-output-monitor
nixd
])
++ (lib.optional useRust config.polyphony.rust.toolchain)
++ (lib.optional useTreefmt config.treefmt.build.wrapper)
++ (cfg.extraPackages);
shellHook = if useGitHooks then config.pre-commit.installationScript else "";
}
// (
if useRust then
{
env.RUST_SRC_PATH = "${config.polyphony.rust.toolchain}/lib/rustlib/src/rust/library";
}
else
{ }
)
);
};
}
);
}