Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dioxus fmt #127

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ This flake exposes a [flake-parts](https://flake.parts/) module as well. To use

For an example, see [haskell-template](https://github.com/srid/haskell-template)'s `flake.nix`.

See [this page](https://zero-to-flakes.com/treefmt-nix) for a detailed walkthrough.
See [this page](https://haskell.flake.page/treefmt) for details.

## Configuration
While dealing with `treefmt` outside of `nix`, the formatter configuration is specified in a `toml` format. On the contrary, with `nix`, you write in with a nix syntax like this:
Expand Down Expand Up @@ -180,6 +180,7 @@ This repo contains a top-level `default.nix` that returns the library helper fun
* deadnix
* deno
* dhall
* dioxus
* dprint
* elm-format
* erlfmt
Expand Down
6 changes: 6 additions & 0 deletions examples/formatter-dioxus.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example generated by ../examples.sh
[formatter.dioxus-cli]
command = "dioxus-fmt"
excludes = []
includes = ["*.rs"]
options = []
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions programs/dioxus.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ lib, pkgs, config, ... }:
let
cfg = config.programs.dioxus;
in
{
options.programs.dioxus = {
enable = lib.mkEnableOption "dioxus";
package = lib.mkPackageOption pkgs "dioxus-cli" { };
};

config = lib.mkIf cfg.enable {
settings.formatter.dioxus = {
command = pkgs.writeShellApplication {
name = "dioxus-fmt";
runtimeInputs = [
cfg.package
];
text = ''
for file in "$@"; do
dx fmt -f "$file"
done
'';
};
includes = [ "*.rs" ];
};
};
}