2023-08-27 07:48:57 +02:00
|
|
|
# flakelight -- Framework for simplifying flake setup
|
2023-08-25 06:14:55 +02:00
|
|
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-11-23 05:55:01 +01:00
|
|
|
{ config, lib, ... }:
|
2023-08-25 06:14:55 +02:00
|
|
|
let
|
2024-02-19 09:11:19 +01:00
|
|
|
inherit (lib) mkDefault mkEnableOption mkIf;
|
2023-08-25 06:14:55 +02:00
|
|
|
in
|
|
|
|
{
|
2023-08-27 07:48:57 +02:00
|
|
|
options.flakelight.builtinFormatters =
|
2023-11-24 01:40:06 +01:00
|
|
|
mkEnableOption "default formatters" //
|
|
|
|
{ default = config.formatter == null; };
|
2023-08-25 06:14:55 +02:00
|
|
|
|
2023-11-23 05:55:01 +01:00
|
|
|
config = mkIf config.flakelight.builtinFormatters {
|
2023-08-25 06:14:55 +02:00
|
|
|
devShell.packages = pkgs: [
|
|
|
|
pkgs.nixpkgs-fmt
|
|
|
|
pkgs.nodePackages.prettier
|
|
|
|
];
|
|
|
|
|
2023-12-06 07:54:01 +01:00
|
|
|
formatters = pkgs:
|
|
|
|
let
|
|
|
|
nixpkgs-fmt = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt";
|
|
|
|
prettier = "${pkgs.nodePackages.prettier}/bin/prettier --write";
|
|
|
|
in
|
|
|
|
{
|
2024-02-19 09:11:19 +01:00
|
|
|
"*.nix" = mkDefault nixpkgs-fmt;
|
|
|
|
"*.md" = mkDefault prettier;
|
|
|
|
"*.json" = mkDefault prettier;
|
|
|
|
"*.yaml" = mkDefault prettier;
|
|
|
|
"*.yml" = mkDefault prettier;
|
2023-12-06 07:54:01 +01:00
|
|
|
};
|
2023-08-25 06:14:55 +02:00
|
|
|
};
|
|
|
|
}
|