aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: 7d0e3800396939867977221b6c55633e8d5db53b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
  description = "My Completely Inelegant Neovim Flake";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          # This is where I import any custom packages that I want to install. By
          # placing them in the overlay the become available in 'pkgs' further
          # below.
          overlays = [
            (self: super: {
              # Kept having issues with ones in stable and unstable so built custom revision
              vale = super.callPackage ./nix/vale.nix { };
              # Wasn't packaged
              flake8-isort =
                super.python3Packages.callPackage ./nix/flake8-isort.nix { };
              # Python with linting and such
              mypython =
                super.python3Packages.callPackage ./nix/mypython.nix { };
              # Wasn't packaged
              vim-angry-reviewer =
                super.callPackage ./nix/vim-angry-reviewer.nix { };
            })
          ];
        };
      in rec {
        # For nix < 2.7
        # For nix >= 2.7 they should grab automatically from:
        #     apps.${system}.default
        #     packages.${system}.default
        defaultApp = apps.${system}.default;
        defaultPackage = packages.${system}.default;

        apps = rec {
          nvim = flake-utils.lib.mkApp {
            type = "app";
            program = "${packages.${system}.default}/bin/nvim";
          };
          default = nvim;
        };
        packages = with pkgs;
          let
            # My custom neovim with my init file and all the plugins I use.
            myneovim = (neovim.override {
              configure = {
                # customRC expects vimscript but I've already converted to lua
                customRC = ''
                  lua << EOF
                  ${pkgs.lib.readFile ./init.lua}
                  EOF
                  " lua doesn't like the special characters
                  nnoremap <leader>pl vipJV:s/[.!?]  */&
/g
:noh
                  let g:languagetool_server_command = '${languagetool}/bin/languagetool-http-server'
                '';
                packages.myPlugins = with vimPlugins; {
                  start = [
                    # Colorscheme
                    gruvbox-nvim

                    # Syntax coloring
                    nvim-ts-rainbow
                    nvim-treesitter.withAllGrammars

                    # Autocompletes
                    nvim-lspconfig
                    nvim-cmp
                    cmp-nvim-lsp

                    # File navigation
                    lf-vim
                    vim-floaterm

                    # The rest
                    vim-commentary
                    vim-surround
                    vim-repeat
                    fzf-vim
                    vim-argwrap
                    vim-fugitive
                    indent-blankline-nvim
                    camelcasemotion
                    hop-nvim
                    ale
                    goyo-vim
                    vim-oscyank
                    ack-vim
                    vim-angry-reviewer
                    LanguageTool-nvim
                    camelcasemotion
                    vim-table-mode
                    vim-bufkill
                    emmet-vim
                    tagbar
                    vim-markdown
                    vim-go
                  ];
                };
              };
            });
          in rec {
            default = neovimCH;
            # symlinkJoin might not be the best solution here but it worked so I
            # just use it for now.
            neovimCH = symlinkJoin {
              name = "neovim";
              paths = [ myneovim ];
              buildInputs = [ pkgs.makeWrapper ];
              postBuild = with pkgs; ''
                rm $out/bin/nvim
                BINPATH=${
                  lib.makeBinPath [
                    ctags
                    gcc
                    nodejs
                    mypython
                    pyright
                    vale
                    tree-sitter
                    nodePackages.bash-language-server
                    shellcheck
                    hadolint
                    nixfmt
                    languagetool
                    lf
                    terraform-ls
                    ansible-language-server
                    ansible-lint
                    ansible
                    go
                    gotools
                  ]
                }
                makeWrapper ${myneovim}/bin/nvim $out/bin/nvim --prefix PATH : $BINPATH
              '';
            };
          };
      });
}