@@ -0,0 +1,35 @@
1+{ fetchFromGitHub
2+, lib
3+, rustPlatform
4+, stdenvNoCC
5+, lua52Support ? true
6+, luauSupport ? false
7+}:
8+
9+rustPlatform.buildRustPackage rec {
10+ pname = "stylua";
11+ version = "0.8.1";
12+
13+ src = fetchFromGitHub {
14+ owner = "johnnymorganz";
15+ repo = pname;
16+ rev = "v${version}";
17+ sha256 = "0gjm9pvwfbwhd49pm5sw5plwhlhvbfkms44h67zgvy7xzqv8h3dw";
18+ };
19+
20+ cargoSha256 = "117m78naldp6yvwcccvsrbnx6x6287cvq0saa06pmiqv1rqm50m3";
21+
22+ cargoBuildFlags = lib.optionals lua52Support [ "--features" "lua52" ]
23+ ++ lib.optionals luauSupport [ "--features" "luau" ];
24+
25+ # test_standard fails on darwin
26+ doCheck = !stdenvNoCC.isDarwin;
27+
28+ meta = with lib; {
29+ description = "An opinionated Lua code formatter";
30+ homepage = "https://github.com/johnnymorganz/stylua";
31+ changelog = "https://github.com/johnnymorganz/stylua/blob/v${version}/CHANGELOG.md";
32+ license = licenses.mpl20;
33+ maintainers = with maintainers; [ figsoda ];
34+ };
35+}