{
  description = "A very basic flake";

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

  outputs = inputs@{ self, flake-utils, nixpkgs, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = {};
          overlays = [
            (final: prev:
              let
                vim-eskk = prev.vimUtils.buildVimPlugin {
                  name = "vim-eskk";
                  src = inputs.eskk-vim;
                };
              in
              {
                vimPlugins = prev.vimPlugins // {
                  inherit vim-eskk;
                };
              }
            )
          ];
        };
        lualibs = with pkgs.lua53Packages; [
          lyaml
        ];
        myvim = pkgs.vim_configurable.customize {
          name = "vim-nit-latex";
          vimrcConfig.customRC = ''
            filetype on
            set encoding=utf-8
            set autoindent
            set smartindent
            set shiftwidth=4
            set tabstop=4
            set smarttab
            set expandtab
            set wrap

            syntax enable

            set cursorline
            set mousehide
            set ruler
            set number relativenumber
            set nospell

            set magic
            set ignorecase
            set smartcase
            set hlsearch
            set incsearch

            let g:eskk#directory = "~/.config/eskk"
            let g:eskk#dictionary = { 'path': "~/.config/eskk/jisyo", 'sorted': 1, 'encoding': 'utf-8', }
            let g:eskk#large_dictionary = { 'path': "~/.config/eskk/SKK-JISYO.L", 'sorted': 1, 'encoding': 'euc-jp', }
            let g:eskk#kakutei_when_unique_candidate = 0
            let g:eskk#enable_completion = 0
            let g:eskk#no_default_mappings = 1
            let g:eskk#keep_state = 0
            let g:eskk#egg_like_newline = 1

            let g:toggle_latex_eskk = 1
            function! s:latex_eskk() abort
                if &filetype == 'tex' && g:toggle_latex_eskk ==# 1
                    call eskk#enable()
                endif
            endfunction

            function! s:latex_eskk_toggle() abort
                let g:toggle_latex_eskk = g:toggle_latex_eskk == 1 ? 0 : 1
                if g:toggle_latex_eskk ==# 1
                    echomsg 'LaTeX Japanese Input Enabled'
                else
                    echomsg 'LaTeX Japanese Input Disabled'
                endif
            endfunction

            augroup vimrc_eskk
                autocmd!
                autocmd InsertEnter * call s:latex_eskk()
                autocmd Filetype tex nnoremap <buffer><silent> <F1> :call <SID>latex_eskk_toggle()<CR>
                autocmd User eskk-enable-post lmap <buffer> l <Plug>(eskk:disable)
            augroup END
                  
            imap jk <Plug>(eskk:toggle)
            cmap jk <Plug>(eskk:toggle)
          '';
          vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
            start = [ vim-eskk ];
            opt = [];
          };
        };
        mytexlive = pkgs.texliveBasic.withPackages
          (ps: [
            ps.biber
            ps.biblatex
            ps.bibtex
            ps.babel
            ps.latexmk
            ps.csquotes
            ps.digestif
            ps.import
            ps.subfiles
            ps.wrapfig
            ps.collection-langjapanese
            ps.amsmath
            ps.amsfonts
            ps.mathtools
            ps.listings
            ps.luatexja
            ps.luainputenc
            ps.lualatex-math
            ps.luacode
            ps.enumitem
            ps.latex-fonts
            ps.hyperref
            ps.graphics
            ps.xcolor
            ps.xpatch
            ps.xstring
            ps.float
            ps.framed
            ps.fontspec
            ps.ninecolors
            ps.here
            ps.caption
            ps.newtx
            ps.tabularray
          ]);
      in
      {
        devShells.default = pkgs.stdenv.mkDerivation {
          name = "LaTeX Environment";
          shellHook = ''
            export PS1="NIT Report \w \$ "
          '';
          nativeBuildInputs = [
            mytexlive
            myvim
            pkgs.pandoc
            pkgs.qpdf
            pkgs.mermaid-cli
          ] ++ lualibs;
        };
      }
    );
}
