From cececba08fa7cb39a24d0f2c97aebf3dfd70a2cf Mon Sep 17 00:00:00 2001 From: michzappa <59343378+michzappa@users.noreply.github.com> Date: Mon, 16 May 2022 00:36:47 -0400 Subject: Add nixfmt (#98) * Add nixfmt * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Radon Rosborough --- CHANGELOG.md | 5 ++++- apheleia.el | 2 ++ test/formatters/installers/nixfmt.bash | 4 ++++ test/formatters/samplecode/nixfmt/in.nix | 13 +++++++++++++ test/formatters/samplecode/nixfmt/out.nix | 15 +++++++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/formatters/installers/nixfmt.bash create mode 100644 test/formatters/samplecode/nixfmt/in.nix create mode 100644 test/formatters/samplecode/nixfmt/out.nix diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f601ec..55a76de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,8 @@ The format is based on [Keep a Changelog]. * [dart-format](https://dart.dev/tools/dart-format) for Dart ([#89]). * [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for PHP ([#87]). -* [ktlint](https://github.com/pinterest/ktlint) for Kotlin ([#95]). +* [ktlint](https://github.com/pinterest/ktlint) for Kotlin ([#97]). +* [nixfmt](https://github.com/serokell/nixfmt) for Nix ([#98]). ### Features * Support remote files and buffers that were opened through TRAMP @@ -31,6 +32,8 @@ The format is based on [Keep a Changelog]. [#87]: https://github.com/raxod502/apheleia/pull/87 [#89]: https://github.com/raxod502/apheleia/pull/89 [#94]: https://github.com/radian-software/apheleia/pull/94 +[#97]: https://github.com/radian-software/apheleia/pull/97 +[#98]: https://github.com/radian-software/apheleia/pull/98 ## 2.0 ### Breaking changes diff --git a/apheleia.el b/apheleia.el index c71121c..1cb1e29 100644 --- a/apheleia.el +++ b/apheleia.el @@ -930,6 +930,7 @@ being run, for diagnostic purposes." (ktlint . ("ktlint" "--stdin" "-F")) (latexindent . ("latexindent" "--logfile=/dev/null")) (mix-format . ("mix" "format" "-")) + (nixfmt . ("nixfmt")) (ocamlformat . ("ocamlformat" "-" "--name" filepath "--enable-outside-detected-project")) (phpcs . ("apheleia-phpcs")) @@ -1063,6 +1064,7 @@ function: %s" command))) (kotlin-mode . ktlint) (latex-mode . latexindent) (LaTeX-mode . latexindent) + (nix-mode . nixfmt) (python-mode . black) (ruby-mode . prettier) (rustic-mode . rustfmt) diff --git a/test/formatters/installers/nixfmt.bash b/test/formatters/installers/nixfmt.bash new file mode 100644 index 0000000..213a59b --- /dev/null +++ b/test/formatters/installers/nixfmt.bash @@ -0,0 +1,4 @@ +ver="$(latest_release serokell/nixfmt)" + +wget "https://github.com/serokell/nixfmt/releases/download/${ver}/nixfmt" -O /usr/local/bin/nixfmt +chmod +x /usr/local/bin/nixfmt diff --git a/test/formatters/samplecode/nixfmt/in.nix b/test/formatters/samplecode/nixfmt/in.nix new file mode 100644 index 0000000..9f804c8 --- /dev/null +++ b/test/formatters/samplecode/nixfmt/in.nix @@ -0,0 +1,13 @@ +{ + + nixpkgs = { + config.allowUnfree = true; + overlays = [ (final: prev: { + unstable = import self.inputs.nixpkgs-unstable { system = system; + config.allowUnfree = true; + }; + }) + ]; + }; + +} diff --git a/test/formatters/samplecode/nixfmt/out.nix b/test/formatters/samplecode/nixfmt/out.nix new file mode 100644 index 0000000..d9965e9 --- /dev/null +++ b/test/formatters/samplecode/nixfmt/out.nix @@ -0,0 +1,15 @@ +{ + + nixpkgs = { + config.allowUnfree = true; + overlays = [ + (final: prev: { + unstable = import self.inputs.nixpkgs-unstable { + system = system; + config.allowUnfree = true; + }; + }) + ]; + }; + +} -- cgit v1.0