diff --git a/home/jonas@comfy-station.nix b/home/jonas@comfy-station.nix index f8cb7a1..80ded7f 100644 --- a/home/jonas@comfy-station.nix +++ b/home/jonas@comfy-station.nix @@ -33,6 +33,10 @@ age.keyFile = "${home.homeDirectory}/.config/sops/age/keys.txt"; }; + doom.enable = true; + doom.withNixPkgs = true; + doom.withShellPkgs = true; + # Make session variables available in systemd units # SEE: https://github.com/nix-community/home-manager/pull/5543 # systemd.user.settings.Manager.DefaultEnvironment = diff --git a/modules/home/doom/doom.nix b/modules/home/doom/doom.nix index 328bf6e..2007465 100644 --- a/modules/home/doom/doom.nix +++ b/modules/home/doom/doom.nix @@ -4,48 +4,53 @@ lib, ... }: let + cfg = config.doom; doom-pkgs = with pkgs; [ fira fira-code-nerdfont emacs-all-the-icons-fonts ]; - doom-path-pkgs = with pkgs; [ + default-core-pkgs = with pkgs; [ (ripgrep.override {withPCRE2 = true;}) - alejandra (aspellWithDicts (d: [d.en d.de d.en-computers d.en-science])) binutils - ccls - clang-tools - cmake editorconfig-core-c - emmet-ls fd - gcc - gdb git gnumake gnutls - graphviz - imagemagick ispell libtool - lldb - mermaid-filter - mlocate + ]; + default-shell-pkgs = with pkgs; [ + emmet-ls + ]; + default-nix-pkgs = with pkgs; [ + alejandra nixd - nodejs_22 + ]; + default-latex-pkgs = with pkgs; [ pandoc - pandoc-katex poppler - python311 - python311Packages.debugpy - python311Packages.grip texlab texlive.combined.scheme-medium - unzip - zlib - zstd ]; + default-cxx-pkgs = with pkgs; [ + clang + clang-format + clang-tools + cmake + cppcheck + doxygen + gdb + ninja + ]; + doom-path-pkgs = + lib.optionals cfg.withLatexPkgs (cfg.overrideLatexPkgs default-latex-pkgs) + ++ lib.optionals cfg.withShellPkgs (cfg.overrideShellPkgs default-shell-pkgs) + ++ lib.optionals cfg.withNixPkgs (cfg.overrideNixPkgs default-nix-pkgs) + ++ lib.optionals cfg.withCXXPkgs (cfg.overrideCXXPkgs default-cxx-pkgs) + ++ default-core-pkgs; doom-socket-name = "main"; wrapped-emacs = pkgs.symlinkJoin { name = "wrapped-emacs"; @@ -76,97 +81,147 @@ fi ''; in { - programs.emacs = { - enable = true; - package = wrapped-emacs; - }; - - home = { - sessionPath = ["${config.xdg.configHome}/doom-emacs/bin"]; - sessionVariables = { - DOOMDIR = "${config.xdg.configHome}/doom-config"; - DOOMLOCALDIR = "${config.xdg.configHome}/doom-local"; + options.doom = { + enable = lib.mkEnableOption "Enable Doom Emacs"; + withLatexPkgs = lib.mkEnableOption "Enable LaTeX packages in doom path"; + withShellPkgs = lib.mkEnableOption "Enable shell packages in doom path"; + withNixPkgs = lib.mkEnableOption "Enable LaTeX packages in doom path"; + withCXXPkgs = lib.mkEnableOption "Enable CXX packages in doom path"; + overrideLatexPkgs = lib.mkOption { + type = lib.types.functionTo (lib.types.listOf lib.types.package); + default = pkgs: pkgs; + example = '' + prev: with pkgs; [ + texlive.combined.scheme-full + ] + ''; + description = "Override the default LaTeX packages in the doom path."; + }; + overrideShellPkgs = lib.mkOption { + type = lib.types.functionTo (lib.types.listOf lib.types.package); + default = pkgs: pkgs; + example = '' + prev: with pkgs; [ + shellcheck + ] + ''; + description = "Override the default shell packages in the doom path."; + }; + overrideNixPkgs = lib.mkOption { + type = lib.types.functionTo (lib.types.listOf lib.types.package); + default = pkgs: pkgs; + example = '' + prev: with pkgs; [ + nixpkgs-fmt + ] + ''; + description = "Override the default Nix packages in the doom path."; + }; + overrideCXXPkgs = lib.mkOption { + type = lib.types.functionTo (lib.types.listOf lib.types.package); + default = pkgs: pkgs; + example = '' + prev: with pkgs; [ + openmp + ] + ''; + description = "Override the default C++ packages in the doom path."; }; }; - systemd.user.services.doom-emacs-server = { - Unit = { - Description = "Doom Emacs Server"; + config = lib.mkIf cfg.enable { + programs.emacs = { + enable = true; + package = wrapped-emacs; }; - Service = { - ExecStart = "${wrapped-emacs}/bin/emacs --fg-daemon=${doom-socket-name}"; - SuccessExitStatus = 15; - }; - Install = { - WantedBy = []; # Lazy start by socket - }; - }; - systemd.user.sockets.doom-emacs-server = { - Socket = { - ListenStream = "/run/user/%U/emacs/${doom-socket-name}"; - DirectoryMode = "0700"; - }; - Install = { - WantedBy = ["sockets.target"]; - }; - }; - xdg = { - enable = true; - configFile = { - "doom-config/splash.png" = { - source = ./static/splash.png; - }; - "doom-config/config.el" = { - source = ./static/config.el; - }; - "doom-config/packages/treesit-docgen.el" = { - source = ./static/packages/treesit-docgen.el; - }; - "doom-config/init.el" = { - source = ./static/init.el; - onChange = "${doom-setup} sync --force -e"; - }; - "doom-config/packages.el" = { - source = ./static/packages.el; - onChange = "${doom-setup} sync --force -u -e"; - }; - "doom-emacs" = { - source = builtins.fetchGit { - url = "https://github.com/doomemacs/doomemacs"; - rev = "466490c252d06f42a9c165f361de74a6e6abad8d"; - }; - onChange = "${doom-setup} --force sync -u -e"; + home = { + sessionPath = ["${config.xdg.configHome}/doom-emacs/bin"]; + sessionVariables = { + DOOMDIR = "${config.xdg.configHome}/doom-config"; + DOOMLOCALDIR = "${config.xdg.configHome}/doom-local"; }; }; - desktopEntries = { - emacs = { - name = "Doom Emacs"; - genericName = "Text Editor"; - icon = ./static/icon.png; - exec = "${wrapped-emacs}/bin/emacs %F"; - terminal = false; - categories = ["Application" "Development" "TextEditor"]; - mimeType = ["text/*"]; - settings = { - StartupWMClass = "Doom Emacs"; + + systemd.user.services.doom-emacs-server = { + Unit = { + Description = "Doom Emacs Server"; + }; + Service = { + ExecStart = "${wrapped-emacs}/bin/emacs --fg-daemon=${doom-socket-name}"; + SuccessExitStatus = 15; + }; + Install = { + WantedBy = []; # Lazy start by socket + }; + }; + systemd.user.sockets.doom-emacs-server = { + Socket = { + ListenStream = "/run/user/%U/emacs/${doom-socket-name}"; + DirectoryMode = "0700"; + }; + Install = { + WantedBy = ["sockets.target"]; + }; + }; + + xdg = { + enable = true; + configFile = { + "doom-config/splash.png" = { + source = ./static/splash.png; + }; + "doom-config/config.el" = { + source = ./static/config.el; + }; + "doom-config/packages/treesit-docgen.el" = { + source = ./static/packages/treesit-docgen.el; + }; + "doom-config/init.el" = { + source = ./static/init.el; + onChange = "${doom-setup} sync --force -e"; + }; + "doom-config/packages.el" = { + source = ./static/packages.el; + onChange = "${doom-setup} sync --force -u -e"; + }; + "doom-emacs" = { + source = builtins.fetchGit { + url = "https://github.com/doomemacs/doomemacs"; + rev = "466490c252d06f42a9c165f361de74a6e6abad8d"; + }; + onChange = "${doom-setup} --force sync -u -e"; }; }; - emacsclient = { - name = "Doom Emacs (Client)"; - genericName = "Text Editor"; - icon = ./static/icon.png; - exec = '' - sh -c "if [ -n \\"\\$*\\" ]; then exec ${wrapped-emacs}/bin/emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" sh %F - ''; - terminal = false; - categories = ["Application" "Development" "TextEditor"]; - mimeType = ["text/*"]; - settings = { - StartupWMClass = "Doom Emacs"; + desktopEntries = { + emacs = { + name = "Doom Emacs"; + genericName = "Text Editor"; + icon = ./static/icon.png; + exec = "${wrapped-emacs}/bin/emacs %F"; + terminal = false; + categories = ["Application" "Development" "TextEditor"]; + mimeType = ["text/*"]; + settings = { + StartupWMClass = "Doom Emacs"; + }; + }; + emacsclient = { + name = "Doom Emacs (Client)"; + genericName = "Text Editor"; + icon = ./static/icon.png; + exec = '' + sh -c "if [ -n \\"\\$*\\" ]; then exec ${wrapped-emacs}/bin/emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" sh %F + ''; + terminal = false; + categories = ["Application" "Development" "TextEditor"]; + mimeType = ["text/*"]; + settings = { + StartupWMClass = "Doom Emacs"; + }; }; }; }; + home.packages = doom-pkgs; }; - home.packages = doom-pkgs; }