Home Gen494 @ 2025-04-09-12:54

This commit is contained in:
Jonas Röger 2025-04-09 12:54:45 +02:00
parent 5b22736b9f
commit 22c02c6184
2 changed files with 160 additions and 101 deletions

View File

@ -33,6 +33,10 @@
age.keyFile = "${home.homeDirectory}/.config/sops/age/keys.txt"; 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 # Make session variables available in systemd units
# SEE: https://github.com/nix-community/home-manager/pull/5543 # SEE: https://github.com/nix-community/home-manager/pull/5543
# systemd.user.settings.Manager.DefaultEnvironment = # systemd.user.settings.Manager.DefaultEnvironment =

View File

@ -4,48 +4,53 @@
lib, lib,
... ...
}: let }: let
cfg = config.doom;
doom-pkgs = with pkgs; [ doom-pkgs = with pkgs; [
fira fira
fira-code-nerdfont fira-code-nerdfont
emacs-all-the-icons-fonts emacs-all-the-icons-fonts
]; ];
doom-path-pkgs = with pkgs; [ default-core-pkgs = with pkgs; [
(ripgrep.override {withPCRE2 = true;}) (ripgrep.override {withPCRE2 = true;})
alejandra
(aspellWithDicts (d: [d.en d.de d.en-computers d.en-science])) (aspellWithDicts (d: [d.en d.de d.en-computers d.en-science]))
binutils binutils
ccls
clang-tools
cmake
editorconfig-core-c editorconfig-core-c
emmet-ls
fd fd
gcc
gdb
git git
gnumake gnumake
gnutls gnutls
graphviz
imagemagick
ispell ispell
libtool libtool
lldb ];
mermaid-filter default-shell-pkgs = with pkgs; [
mlocate emmet-ls
];
default-nix-pkgs = with pkgs; [
alejandra
nixd nixd
nodejs_22 ];
default-latex-pkgs = with pkgs; [
pandoc pandoc
pandoc-katex
poppler poppler
python311
python311Packages.debugpy
python311Packages.grip
texlab texlab
texlive.combined.scheme-medium 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"; doom-socket-name = "main";
wrapped-emacs = pkgs.symlinkJoin { wrapped-emacs = pkgs.symlinkJoin {
name = "wrapped-emacs"; name = "wrapped-emacs";
@ -76,97 +81,147 @@
fi fi
''; '';
in { in {
programs.emacs = { options.doom = {
enable = true; enable = lib.mkEnableOption "Enable Doom Emacs";
package = wrapped-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";
home = { withCXXPkgs = lib.mkEnableOption "Enable CXX packages in doom path";
sessionPath = ["${config.xdg.configHome}/doom-emacs/bin"]; overrideLatexPkgs = lib.mkOption {
sessionVariables = { type = lib.types.functionTo (lib.types.listOf lib.types.package);
DOOMDIR = "${config.xdg.configHome}/doom-config"; default = pkgs: pkgs;
DOOMLOCALDIR = "${config.xdg.configHome}/doom-local"; 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 = { config = lib.mkIf cfg.enable {
Unit = { programs.emacs = {
Description = "Doom Emacs Server"; 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 = { home = {
enable = true; sessionPath = ["${config.xdg.configHome}/doom-emacs/bin"];
configFile = { sessionVariables = {
"doom-config/splash.png" = { DOOMDIR = "${config.xdg.configHome}/doom-config";
source = ./static/splash.png; DOOMLOCALDIR = "${config.xdg.configHome}/doom-local";
};
"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";
}; };
}; };
desktopEntries = {
emacs = { systemd.user.services.doom-emacs-server = {
name = "Doom Emacs"; Unit = {
genericName = "Text Editor"; Description = "Doom Emacs Server";
icon = ./static/icon.png; };
exec = "${wrapped-emacs}/bin/emacs %F"; Service = {
terminal = false; ExecStart = "${wrapped-emacs}/bin/emacs --fg-daemon=${doom-socket-name}";
categories = ["Application" "Development" "TextEditor"]; SuccessExitStatus = 15;
mimeType = ["text/*"]; };
settings = { Install = {
StartupWMClass = "Doom Emacs"; 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 = { desktopEntries = {
name = "Doom Emacs (Client)"; emacs = {
genericName = "Text Editor"; name = "Doom Emacs";
icon = ./static/icon.png; genericName = "Text Editor";
exec = '' icon = ./static/icon.png;
sh -c "if [ -n \\"\\$*\\" ]; then exec ${wrapped-emacs}/bin/emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" sh %F exec = "${wrapped-emacs}/bin/emacs %F";
''; terminal = false;
terminal = false; categories = ["Application" "Development" "TextEditor"];
categories = ["Application" "Development" "TextEditor"]; mimeType = ["text/*"];
mimeType = ["text/*"]; settings = {
settings = { StartupWMClass = "Doom Emacs";
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;
} }