robin/weave

simple neovim wrapper for nix

git clone https://git.robinwobin.dev/robin/weave

isabelfeat: initd91c635

main
1.9 KiB83 linesraw
1{
2  inputs = {
3    nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
4  };
5
6  outputs =
7    {
8      self,
9      nixpkgs,
10    }:
11    let
12      inherit (nixpkgs) lib;
13
14      forAllSystems =
15        f: lib.genAttrs lib.systems.flakeExposed (system: f nixpkgs.legacyPackages.${system});
16
17      mkPkgs = pkgs: import ./default.nix { inherit pkgs; };
18    in
19    {
20      formatter = forAllSystems (
21        pkgs:
22        pkgs.treefmt.withConfig {
23          runtimeInputs = with pkgs; [
24            # keep-sorted start
25            deadnix
26            keep-sorted
27            nixfmt-rfc-style
28            statix
29            stylua
30            taplo
31            # keep-sorted end
32
33            (writeShellScriptBin "statix-fix" ''
34              for file in "$@"; do
35                ${lib.getExe statix} fix "$file"
36              done
37            '')
38          ];
39
40          settings = {
41            on-unmatched = "info";
42            tree-root-file = "flake.nix";
43
44            formatter = {
45              # keep-sorted start block=yes newline_separated=yes
46              deadnix = {
47                command = "deadnix";
48                includes = [ "*.nix" ];
49              };
50
51              keep-sorted = {
52                command = "keep-sorted";
53                includes = [ "*" ];
54              };
55
56              nixfmt = {
57                command = "nixfmt";
58                includes = [ "*.nix" ];
59              };
60
61              statix = {
62                command = "statix-fix";
63                includes = [ "*.nix" ];
64              };
65              # keep-sorted end
66            };
67          };
68        }
69      );
70
71      legacyPackages = forAllSystems mkPkgs;
72      packages = forAllSystems mkPkgs;
73      overlays.default = _: mkPkgs;
74
75      devShells = forAllSystems (pkgs: {
76        default = pkgs.mkShellNoCC {
77          inputsFrom = [
78            self.formatter.${pkgs.stdenv.hostPlatform.system}
79          ];
80        };
81      });
82    };
83}