emacs server

This commit is contained in:
Philipp Hochkamp 2022-09-05 21:30:29 +02:00
parent 8af7ea5958
commit 0378909589
4 changed files with 112 additions and 84 deletions

View file

@ -1,7 +1,7 @@
{ inputs, config, lib, pkgs, ... }: { inputs, config, lib, pkgs, ... }:
{ {
home.stateVersion = lib.mkDefault "21.05"; home.stateVersion = lib.mkDefault "22.05";
home.packages = with pkgs; [ home.packages = with pkgs; [
my.scripts my.scripts
@ -46,34 +46,34 @@
}; };
programs = { programs = {
gpg = { # gpg = {
enable = true; # enable = true;
settings = { # settings = {
cert-digest-algo = "SHA512"; # cert-digest-algo = "SHA512";
charset = "utf-8"; # charset = "utf-8";
default-preference-list = "SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed"; # default-preference-list = "SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed";
auto-key-retrieve = true; # auto-key-retrieve = true;
fixed-list-mode = true; # fixed-list-mode = true;
keyserver = "hkps://keyserver.ubuntu.com:443"; # keyserver = "hkps://keyserver.ubuntu.com:443";
list-options = [ "show-uid-validity" "show-unusable-subkeys" ]; # list-options = [ "show-uid-validity" "show-unusable-subkeys" ];
no-comments = true; # no-comments = true;
no-emit-version = true; # no-emit-version = true;
no-greeting = true; # no-greeting = true;
no-symkey-cache = true; # no-symkey-cache = true;
personal-cipher-preferences = "AES256 AES192 AES"; # personal-cipher-preferences = "AES256 AES192 AES";
personal-compress-preferences = "ZLIB BZIP2 ZIP Uncompressed"; # personal-compress-preferences = "ZLIB BZIP2 ZIP Uncompressed";
personal-digest-preferences = "SHA512 SHA384 SHA256"; # personal-digest-preferences = "SHA512 SHA384 SHA256";
require-cross-certification = true; # require-cross-certification = true;
s2k-cipher-algo = "AES256"; # s2k-cipher-algo = "AES256";
s2k-digest-algo = "SHA512"; # s2k-digest-algo = "SHA512";
throw-keyids = true; # throw-keyids = true;
use-agent = true; # use-agent = true;
verbose = true; # verbose = true;
verify-options = "show-uid-validity"; # verify-options = "show-uid-validity";
with-fingerprint = true; # with-fingerprint = true;
with-key-origin = true; # with-key-origin = true;
}; # };
}; # };
bat = { bat = {
enable = true; enable = true;
config.theme = "gruvbox-dark"; config.theme = "gruvbox-dark";

View file

@ -47,3 +47,9 @@ n ()
rm -f "$NNN_TMPFILE" > /dev/null rm -f "$NNN_TMPFILE" > /dev/null
fi fi
} }
ORIGTMPDIR=$TMPDIR # nix-shell overrides tmpdir, but we want to save it
emacsclient ()
{
command emacsclient -s $ORIGTMPDIR/emacs$(id -u)/server "$@"
}

View file

@ -1,12 +1,18 @@
{ pkgs, inputs, lib, ... }: { pkgs, inputs, lib, ... }:
with lib; with lib;
with lib.my; with lib.my;
let
myEmacs = pkgs.emacsNativeComp;
in
{ {
users.users.ragon = { users.users.ragon = {
name = "ragon"; name = "ragon";
home = "/Users/ragon"; home = "/Users/ragon";
}; };
environment.systemPackages = [
myEmacs
];
homebrew = { homebrew = {
enable = true; enable = true;
@ -42,61 +48,74 @@ with lib.my;
#}; #};
}; };
programs.gnupg.agent.enable = true; launchd.user.agents.emacsdaemon = {
home-manager.users.ragon = { pkgs, lib, inputs, config, ... }: { script = "${myEmacs}/Applications/Emacs.app/Contents/MacOS/Emacs --daemon";
home.file.".hammerspoon/init.lua".source = ./hammerspoon.lua; serviceConfig.RunAtLoad = true;
serviceConfig.UserName = "ragon";
programs.home-manager.enable = true; serviceConfig.KeepAlive = true;
home.stateVersion = "21.11"; serviceConfig.WorkingDirectory = "/Users/ragon";
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
PATH = "$PATH:$HOME/go/bin:$HOME/development/flutter/bin:/Applications/Android Studio.app/Contents/bin/:/Applications/Docker.app/Contents/Resources/bin:/Applications/Android Studio.app/Contents/jre/Contents/Home/bin";
JAVA_HOME = "/Applications/Android Studio.app/Contents/jre/Contents/Home/";
};
home.packages = with pkgs; [
terraform-ls
terraform
emacsNativeComp
cmake
pandoc
texlive.combined.scheme-full
yabai
google-cloud-sdk
];
home.activation = {
aliasApplications =
let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
# Install MacOS applications to the user environment.
HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state
[ -e "$HM_APPS" ] && $DRY_RUN_CMD rm -r "$HM_APPS"
$DRY_RUN_CMD mkdir -p "$HM_APPS"
# .app dirs need to be actual directories for Finder to detect them as Apps.
# The files inside them can be symlinks though.
$DRY_RUN_CMD cp --recursive --symbolic-link --no-preserve=mode -H ${apps}/Applications/* "$HM_APPS" || true # can fail if no apps exist
# Modes need to be stripped because otherwise the dirs wouldn't have +w,
# preventing us from deleting them again
# In the env of Apps we build, the .apps are symlinks. We pass all of them as
# arguments to cp and make it dereference those using -H
'';
};
}; };
programs.gnupg.agent.enable = true;
home-manager.users.ragon = { pkgs, lib, inputs, config, ... }:
{
home.file.".hammerspoon/init.lua".source =
pkgs.substituteAll {
src = ./hammerspoon.lua; inherit myEmacs; };
programs.home-manager.enable = true;
home.stateVersion = "21.11";
home.shellAliases = {
v = lib.mkForce "emacsclient -t";
vv = lib.mkForce "emacsclient -c";
};
home.sessionVariables = {
EDITOR = "emacsclient -t";
VISUAL = "emacsclient -c";
PATH = "$PATH:$HOME/go/bin:$HOME/development/flutter/bin:/Applications/Android Studio.app/Contents/bin/:/Applications/Docker.app/Contents/Resources/bin:/Applications/Android Studio.app/Contents/jre/Contents/Home/bin";
JAVA_HOME = "/Applications/Android Studio.app/Contents/jre/Contents/Home/";
};
home.packages = with pkgs; [
terraform-ls
terraform
cmake
pandoc
texlive.combined.scheme-full
yabai
google-cloud-sdk
];
home.activation = {
aliasApplications =
let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
# Install MacOS applications to the user environment.
HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state
[ -e "$HM_APPS" ] && $DRY_RUN_CMD rm -r "$HM_APPS"
$DRY_RUN_CMD mkdir -p "$HM_APPS"
# .app dirs need to be actual directories for Finder to detect them as Apps.
# The files inside them can be symlinks though.
$DRY_RUN_CMD cp --recursive --symbolic-link --no-preserve=mode -H ${apps}/Applications/* "$HM_APPS" || true # can fail if no apps exist
# Modes need to be stripped because otherwise the dirs wouldn't have +w,
# preventing us from deleting them again
# In the env of Apps we build, the .apps are symlinks. We pass all of them as
# arguments to cp and make it dereference those using -H
'';
};
};
} }

View file

@ -88,9 +88,12 @@ function showHideBundleId(bundleId)
end end
local hyperModifier = {"cmd", "shift", "ctrl", "alt"} local hyperModifier = {"cmd", "shift", "ctrl", "alt"}
local cmdShiftModifier = {"cmd", "shift"}
hs.hotkey.bind(hyperModifier, "b", function() showHideBundleId("com.bitwarden.desktop") end) hs.hotkey.bind(hyperModifier, "b", function() showHideBundleId("com.bitwarden.desktop") end)
hs.hotkey.bind(hyperModifier, "p", function() showHideBundleId("com.timeular.zei") end) hs.hotkey.bind(hyperModifier, "p", function() showHideBundleId("com.timeular.zei") end)
hs.hotkey.bind(hyperModifier, "l", function() showHideBundleId("com.electron.logseq") end) hs.hotkey.bind(hyperModifier, "l", function() showHideBundleId("com.electron.logseq") end)
hs.hotkey.bind(hyperModifier, "e", function() hs.task.new("@myEmacs@/bin/emacsclient", nil, function() return false end, {"-c"}):start() end)
hs.hotkey.bind(hyperModifier, "i", function() hs.task.new("@myEmacs@/bin/emacsclient", nil, function() return false end, {"--eval", "(emacs-everywhere)"}):start() end)
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
-- Tiling -- Tiling