mirror of
https://github.com/nix-community/flakelight.git
synced 2024-11-21 23:13:09 +01:00
db9da2b1f7
This enables easier overriding of formatting defaults.
34 lines
896 B
Nix
34 lines
896 B
Nix
# flakelight -- Framework for simplifying flake setup
|
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
{ config, lib, ... }:
|
|
let
|
|
inherit (lib) mkDefault mkEnableOption mkIf;
|
|
in
|
|
{
|
|
options.flakelight.builtinFormatters =
|
|
mkEnableOption "default formatters" //
|
|
{ default = config.formatter == null; };
|
|
|
|
config = mkIf config.flakelight.builtinFormatters {
|
|
devShell.packages = pkgs: [
|
|
pkgs.nixpkgs-fmt
|
|
pkgs.nodePackages.prettier
|
|
];
|
|
|
|
formatters = pkgs:
|
|
let
|
|
nixpkgs-fmt = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt";
|
|
prettier = "${pkgs.nodePackages.prettier}/bin/prettier --write";
|
|
in
|
|
{
|
|
"*.nix" = mkDefault nixpkgs-fmt;
|
|
"*.md" = mkDefault prettier;
|
|
"*.json" = mkDefault prettier;
|
|
"*.yaml" = mkDefault prettier;
|
|
"*.yml" = mkDefault prettier;
|
|
};
|
|
};
|
|
}
|