about summary refs log blame commit diff
path: root/users/sterni/emacs/default.nix
blob: 90b408d2d2fe36d4b5b849bd6af1dd85326abaf0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                            
                  

                                 
                              

                                       
                               
                                    

                                   



                                     
                   


                               
                               






                                          








                                       
                     

                                                            
                         



                                                                                                      
 







                               


                                                       
                                    



                                    
        






                                                           
{ depot, pkgs, ... }:

let
  inherit (pkgs.emacsGcc.pkgs) withPackages;

  emacs = withPackages (epkgs: [
    # basic setup
    epkgs.elpaPackages.undo-tree
    epkgs.melpaPackages.evil
    epkgs.melpaPackages.evil-collection
    epkgs.melpaPackages.use-package
    # languages
    epkgs.bqn-mode
    epkgs.elpaPackages.ada-mode
    epkgs.melpaPackages.adoc-mode
    epkgs.melpaPackages.direnv
    epkgs.melpaPackages.dockerfile-mode
    epkgs.melpaPackages.haskell-mode
    epkgs.melpaPackages.jq-mode
    epkgs.melpaPackages.languagetool
    epkgs.melpaPackages.lsp-mode
    epkgs.melpaPackages.lsp-haskell
    epkgs.melpaPackages.markdown-mode
    epkgs.melpaPackages.nix-mode
    epkgs.melpaPackages.sly
    epkgs.melpaPackages.yaml-mode
    epkgs.rust-mode
    epkgs.urweb-mode
    # misc
    epkgs.melpaPackages.hl-todo
    epkgs.melpaPackages.paredit
    epkgs.elpaPackages.rainbow-mode
    epkgs.melpaPackages.rainbow-delimiters
    # beyond text editing
    epkgs.melpaPackages.elfeed
    epkgs.melpaPackages.magit
    epkgs.tvlPackages.tvl
  ]);

  configDirectory = pkgs.symlinkJoin {
    name = "emacs.d";
    paths = [
      ./.
      (pkgs.writeTextFile {
        name = "injected-emacs.d";
        destination = "/nix-inject.el";
        text = ''
          ;; bqn-mode
          (setq bqn-interpreter-path "${pkgs.cbqn}/bin/BQN")

          ;; languagetool
          (setq languagetool-java-bin "${pkgs.jre}/bin/java"
                languagetool-console-command "${pkgs.languagetool}/share/languagetool-commandline.jar"
                languagetool-server-command "${pkgs.languagetool}/share/languagetool-server.jar"
                languagetool-java-arguments '("-Dfile.encoding=UTF-8"))

          (provide 'nix-inject)
        '';
      })
    ];
    postBuild = ''
      rm "$out/default.nix"
    '';
  };
in

# sadly we can't give an init-file via the command line
(pkgs.writeShellScriptBin "emacs" ''
  exec ${emacs}/bin/emacs          \
    --no-init-file                 \
    --directory ${configDirectory} \
    --eval "(require 'init)"       \
    "$@"
'').overrideAttrs (super: {
  buildCommand = ''
    ${super.buildCommand}

    ln -s "${emacs}/bin/emacsclient" "$out/bin/emacsclient"
  '';
})