Emacs in a separate flake

This commit is contained in:
Andrea Ciceri 2023-02-13 00:19:56 +01:00
parent f187dd631f
commit ca14b97b1f
No known key found for this signature in database
GPG key ID: A1FC89532D1C5654
12 changed files with 117 additions and 1058 deletions

View file

@ -1,149 +1,3 @@
{
pkgs,
config,
lib,
...
}: let
emacsMaster =
(pkgs.emacs.override {
nativeComp = true;
withPgtk = true;
withSQLite3 = true;
withGTK3 = true;
})
.overrideAttrs (old: {
src = pkgs.emacsSource;
version = pkgs.emacsSource.rev;
patches = [];
postPatch =
old.postPatch
+ ''
substituteInPlace lisp/loadup.el \
--replace '(emacs-repository-get-version)' '"${pkgs.emacsSource.rev}"' \
--replace '(emacs-repository-get-branch)' '"master"'
''
+ (lib.optionalString (old ? NATIVE_FULL_AOT)
# TODO: remove when https://github.com/NixOS/nixpkgs/pull/193621 is merged
(
let
backendPath =
lib.concatStringsSep " "
(builtins.map (x: ''\"-B${x}\"'') [
# Paths necessary so the JIT compiler finds its libraries:
"${lib.getLib pkgs.libgccjit}/lib"
"${lib.getLib pkgs.libgccjit}/lib/gcc"
"${lib.getLib pkgs.stdenv.cc.libc}/lib"
# Executable paths necessary for compilation (ld, as):
"${lib.getBin pkgs.stdenv.cc.cc}/bin"
"${lib.getBin pkgs.stdenv.cc.bintools}/bin"
"${lib.getBin pkgs.stdenv.cc.bintools.bintools}/bin"
]);
in ''
substituteInPlace lisp/emacs-lisp/comp.el --replace \
"(defcustom comp-libgccjit-reproducer nil" \
"(setq native-comp-driver-options '(${backendPath})) (defcustom comp-libgccjit-reproducer nil"
''
));
});
in {
programs.emacs = {
enable = true;
};
programs.doom-emacs = {
enable = true;
emacsPackage = emacsMaster;
doomPrivateDir = ../../doom.d;
doomPackageDir = pkgs.linkFarm "my-doom-packages" [
{
name = "config.el";
path = pkgs.emptyFile;
}
{
name = "init.el";
path = ../../doom.d/init.el;
}
{
name = "packages.el";
path = ../../doom.d/packages.el;
}
{
name = "modules";
path = ../../doom.d/modules;
}
];
extraPackages = with pkgs; [mu];
};
services.emacs = {
enable = true;
defaultEditor = true;
};
home.packages = with pkgs; let
path = pkgs.lib.makeBinPath [
git
jq
nix
nixpkgs-fmt
];
nixFormat = writeScriptBin "nixFormat" ''
export PATH=${pkgs.lib.escapeShellArg path}
customFormatter=$(nix flake show --no-write-lock-file --no-update-lock-file --json | jq 'has("formatter")')
if [[ $customFormatter == "true" ]]
then
nix fmt <<< /dev/stdin
else
nixpkgs-fmt <<< /dev/stdin
fi
'';
in
[
binutils
(ripgrep.override {withPCRE2 = true;})
gnutls
fd
imagemagick
sqlite
maim
nil
nixFormat
jq
xclip
hunspell
]
++ (with hunspellDicts; [
en_US-large
it_IT
]);
# TODO: probably not the best place, this is unrelated to Emacs
systemd.user.services.second-brain-sync = {
Unit = {Description = "mbsync mailbox synchronization";};
Service = {
Type = "oneshot";
ExecStart = let
sync = pkgs.writeShellScript "second-brain-sync-script" ''
echo ciao
'';
in "${sync}";
};
};
systemd.user.timers.second-brain-sync = {
Unit = {inherit (config.systemd.user.services.second-brain-sync.Unit) Description;};
Timer = {
OnCalendar = "daily";
Unit = "mbsync.service";
Persistent = true;
OnStartupSec = "60m";
};
Install = {WantedBy = ["timers.target"];};
};
ccrEmacs.enable = true;
}

View file

@ -28,7 +28,7 @@
];
profiles.ccr = {
settings = {
"browser.startup.homepage" = "https://google.it";
"browser.startup.homepage" = "https://search.privatevoid.net/";
"browser.search.region" = "IT";
"browser.search.isUS" = false;
"distribution.searchplugins.defaultLocale" = "it-IT";
@ -38,6 +38,23 @@
"browser.download.lastDir" = "/home/ccr/downloads/";
"browser.shell.checkDefaultBrowser" = false;
};
search.force = true;
search.default = "Searx";
search.engines = {
"Searx" = {
urls = [
{
template = "https://search.privatevoid.net/search";
params = [
{
name = "q";
value = "{searchTerms}";
}
];
}
];
};
};
};
};
home.sessionVariables = {

View file

@ -23,14 +23,6 @@ in {
key = config.email;
};
extraConfig = {
url =
if pkgs.stdenv.hostPlatform.isDarwin
then {}
else {
"ssh://git@github.com/" = {insteadOf = https://github.com/;};
};
};
delta = {
enable = true;
options = {

View file

@ -1,63 +0,0 @@
{
config,
pkgs,
...
}: let
# use same version as Doom Emacs
vanillaEmacs = (pkgs.emacsPackagesFor config.programs.doom-emacs.emacsPackage).emacsWithPackages (epkgs:
with epkgs; [
meow
ef-themes
vertico
marginalia
consult
orderless
embark
embark-consult
fira-code-mode
vterm
setup
magit
magit-delta
# git-gutter
# git-gutter-fringe
corfu
corfu-terminal
cape
which-key
nix-mode
envrc
flycheck
flycheck-posframe
flycheck-inline
consult-flycheck
popper
# choose one
lispy
paredit
tree-sitter
tree-sitter-langs
yaml-mode
hl-todo
markdown-mode
polymode # TODO remove if not able to configure it
]);
vanillaEmacsBin = pkgs.writeScriptBin "vanillaEmacs" ''
${vanillaEmacs}/bin/emacs --init-directory ~/.vanilla-emacs.d $@
'';
in {
home.packages = [
vanillaEmacsBin
(
pkgs.makeDesktopItem {
name = "vanilla-emacs";
exec = "vanillaEmacs %u";
comment = "Vanilla Emacs";
desktopName = "vanilla-emacs";
type = "Application";
mimeTypes = [];
}
)
];
}