configuration: changes to emacs and others

This commit is contained in:
Mateusz Słodkowicz 2023-11-13 00:44:03 +01:00
parent c0cd2a0f19
commit cf0c1a685e
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
6 changed files with 223 additions and 71 deletions

View File

@ -32,8 +32,21 @@
# keyMap = "pl"; # keyMap = "pl";
useXkbConfig = true; # use xkbOptions in tty. useXkbConfig = true; # use xkbOptions in tty.
}; };
services.xserver.layout = "pl"; services.xserver.extraLayouts.hyper-pl = {
description = "PL, hyper mod3";
languages = [ "pol" ];
symbolsFile = pkgs.writeText "hyper-pl" ''
xkb_symbols "hyper-pl"
{
include "pl(basic)"
name[Group1]="Polish HYPR";
modifier_map Mod3 { <HYPR> };
};'';
};
services.xserver.layout = "hyper-pl";
services.xserver.xkbOptions = "caps:hyper";
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.videoDrivers = [ "amdgpu" ]; services.xserver.videoDrivers = [ "amdgpu" ];
services.dbus.enable = true; services.dbus.enable = true;
@ -52,7 +65,7 @@
xdg.portal.wlr.enable = true; xdg.portal.wlr.enable = true;
xdg.portal.xdgOpenUsePortal = true; xdg.portal.xdgOpenUsePortal = true;
services.xserver.exportConfiguration = true; services.xserver.exportConfiguration = false;
services.xserver.extraConfig = pkgs.lib.mkDefault '' services.xserver.extraConfig = pkgs.lib.mkDefault ''
Section "OutputClass" Section "OutputClass"
Identifier "amd-options" Identifier "amd-options"
@ -117,6 +130,7 @@
XDG_CONFIG_HOME = "\${HOME}/.config"; XDG_CONFIG_HOME = "\${HOME}/.config";
XDG_BIN_HOME = "\${HOME}/.local/bin"; XDG_BIN_HOME = "\${HOME}/.local/bin";
XDG_DATA_HOME = "\${HOME}/.local/share"; XDG_DATA_HOME = "\${HOME}/.local/share";
QT_XKB_CONFIG_ROOT = "\${XKB_CONFIG_ROOT}";
GTK_IM_MODULE="fcitx"; GTK_IM_MODULE="fcitx";
QT_IM_MODULE="fcitx"; QT_IM_MODULE="fcitx";
XMODIFIERS="@im=fcitx"; XMODIFIERS="@im=fcitx";
@ -193,6 +207,7 @@
};*/ };*/
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
firefox firefox
gamescope gamescope
#(pkgs.lutris.override { extraLibraries = pkgs: with pkgs; [ pkgs.samba pkgs.jansson pkgs.tdb pkgs.libunwind pkgs.libusb1 pkgs.gnutls pkgs.gtk3 pkgs.pango ]; }) #(pkgs.lutris.override { extraLibraries = pkgs: with pkgs; [ pkgs.samba pkgs.jansson pkgs.tdb pkgs.libunwind pkgs.libusb1 pkgs.gnutls pkgs.gtk3 pkgs.pango ]; })
@ -204,7 +219,6 @@
gtk4 gtk4
gsettings-desktop-schemas gsettings-desktop-schemas
libsForQt5.dolphin libsForQt5.dolphin
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
patchelf patchelf

View File

@ -1,20 +1,7 @@
{ config, lib, pkgs, materusArg, ... }: { config, lib, pkgs, materusArg, ... }:
let let
cfg = config.materus.profile.editor.emacs; packages = epkgs: with epkgs; [
configPath = "${materusArg.cfg.path}" + "/extraFiles/config/emacs/"; load-relative
emacsPkgs = with pkgs;[
python3
lua
];
in
{
options.materus.profile.editor.emacs.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable emacs with materus cfg";
config = lib.mkIf cfg.enable {
programs.emacs = {
enable = true;
package = with pkgs; lib.mkDefault (if pkgs ? emacs-pgtk then emacs-pgtk else emacs29-gtk);
extraPackages = epkgs: with epkgs; [
elcord elcord
persp-mode persp-mode
dashboard dashboard
@ -25,6 +12,8 @@ in
vterm vterm
centaur-tabs centaur-tabs
projectile projectile
company
clipetty
treemacs treemacs
treemacs-nerd-icons treemacs-nerd-icons
@ -39,11 +28,16 @@ in
perspective perspective
minions minions
telephone-line telephone-line
rainbow-delimiters
use-package
lsp-mode lsp-mode
lsp-bridge
dap-mode
d-mode d-mode
multiple-cursors
org org
org-rainbow-tags
markdown-mode markdown-mode
json-mode json-mode
nix-mode nix-mode
@ -51,18 +45,95 @@ in
minimap minimap
moe-theme moe-theme
]; ];
extraConfig = ''
;;;; Set emacs PATH
(setenv "PATH" (concat (getenv "PATH") ":${lib.makeBinPath emacsPkgs}"))
${builtins.concatStringsSep "\n" (builtins.map (x: "(setq exec-path (append exec-path '(\""+x+"/bin\")))" ) emacsPkgs)}
;;;; Done setting PATH
;;;; Config
${builtins.readFile (configPath + "config.el")} default-config = ''
;;;; Config End (defvar materus/nix-packages t)
''; (defvar materus/init-from-home nil)
(defvar materus/init-from-default nil)
(when (not materus/init-from-home)
(setq-default materus/init-from-default t)
(message "Config loading not from homeDir, need "materus/init-from-home" variable in init.el")
${setNixInit}
(require 'materus-config)
)
'';
materus-config = epkgs: epkgs.trivialBuild rec {
pname = "materus-config";
src = pkgs.symlinkJoin {
name = "materus-emacs-config";
paths = [
configPath
];
};
version = "1.0";
packageRequires = (packages epkgs);
buildPhase = ''
runHook preBuild
emacs -L . --batch -f batch-byte-compile **/*.el
emacs -L . --batch -f batch-byte-compile *.el
runHook postBuild
'';
installPhase = ''
runHook preInstall
LISPDIR=$out/share/emacs/site-lisp
install -d $LISPDIR
install **.el **.elc $LISPDIR
cp -r materus $LISPDIR
emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
runHook postInstall
'';
};
cfg = config.materus.profile.editor.emacs;
configPath = "${materusArg.cfg.path}" + "/extraFiles/config/emacs/";
emacsPkgs = with pkgs;[
python3
lua
multimarkdown
git
];
setNixInit = ''
(setenv "PATH" (concat (getenv "PATH") ":${lib.makeBinPath emacsPkgs}"))
${builtins.concatStringsSep "\n" (builtins.map (x: "(setq exec-path (append exec-path '(\""+x+"/bin\")))" ) emacsPkgs)}
(call-process-shell-command "${pkgs.xorg.xmodmap}/bin/xmodmap -e \"keycode 66 = Hyper_L\" -e \"remove Mod4 = Hyper_L\" -e \"add Mod3 = Hyper_L\" &" nil 0)
'';
in
{
options.materus.profile.editor.emacs.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable emacs with materus cfg";
config = lib.mkIf cfg.enable {
xdg.configFile."emacs/init.el".text = ''
(defvar materus/nix-packages nil)
(defvar materus/init-from-home t)
(defvar materus/init-from-default nil)
${setNixInit}
(setq-default materus/init-from-home t)
(setq-default materus/nix-packages (require 'materus-config nil 'noerror))
(when (not materus/nix-packages)
(load (concat user-emacs-directory "materus/init"))
(message "Config loaded from user dir")
)
'';
xdg.configFile."emacs/materus" = {
source = configPath + "materus";
recursive = true;
};
programs.emacs = {
enable = true;
package = with pkgs; lib.mkDefault (emacs29.override { withX = true; withGTK3 = true; withAlsaLib = true; withGconf = true; withImageMagick = true; withXwidgets = true; });
extraPackages = epkgs: ((packages epkgs) ++ [(materus-config epkgs)]);
extraConfig = default-config;
}; };
}; };

View File

@ -1,41 +0,0 @@
;Graphical
(when (display-graphic-p)
(set-frame-font "FiraCode Nerd Font" nil t)
(tool-bar-mode -1)
)
(load-theme 'moe-dark)
(setq-default cursor-type '(bar . 1))
(pixel-scroll-precision-mode 1)
(setq pixel-scroll-precision-large-scroll-height 10.0)
(setq mouse-wheel-follow-mouse 't)
(setq scroll-step 1)
(setq mouse-drag-and-drop-region t)
(telephone-line-mode 1)
(minions-mode 1)
;Hide startup screen if started with file
(defun startup-screen-advice (orig-fun &rest args)
(when (= (seq-count #'buffer-file-name (buffer-list)) 0)
(apply orig-fun args)))
(advice-add 'display-startup-screen :around #'startup-screen-advice)
;Enable dashboard
(dashboard-setup-startup-hook)
(when (daemonp)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon
)
:CUA
(cua-mode 1)
(global-set-key (kbd "C-y") 'undo-redo)

View File

@ -0,0 +1,4 @@
(message "Config loading from package")
(setq-default materus/nix-packages t)
(load-relative "materus/init")
(provide 'materus-config)

View File

@ -0,0 +1,96 @@
(defvar materus/nix-packages nil)
(defvar materus/init-from-home nil)
(when (not materus/nix-packages)
(message "Not using config from packages, will compile")
(setq native-comp-async-report-warnings-errors nil)
(setq package-enable-at-startup nil)
(defvar straight-use-package-by-default nil)
(setq straight-use-package-by-default t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(declare-function straight-use-package "straight" (&optional ARG))
(declare-function load-relative "load-relative" (&optional ARG))
(straight-use-package 'load-relative)
(require 'load-relative)
(load-relative "packages")
(if materus/init-from-home
(byte-recompile-directory (concat (expand-file-name user-emacs-directory) "materus/" ) 0)
(byte-recompile-directory (expand-file-name user-emacs-directory) 0))
)
(require 'telephone-line)
(require 'elcord)
(require 'dashboard)
(require 'minions)
;Graphical
(when (display-graphic-p)
(set-frame-font "FiraCode Nerd Font" nil t)
)
(setq custom-file (concat user-emacs-directory "custom.el"))
(when (or (not (display-graphic-p)) (daemonp))
(xterm-mouse-mode 1)
)
(tool-bar-mode -1)
(load-theme 'moe-dark t)
(setq ring-bell-function 'ignore)
(setq-default cursor-type '(bar . 1))
(pixel-scroll-precision-mode 1)
(setq mouse-wheel-follow-mouse 't)
(setq scroll-step 1)
(setq mouse-drag-and-drop-region t)
(telephone-line-mode 1)
(setq-default pixel-scroll-precision-large-scroll-height 10.0)
(minions-mode 1)
(elcord-mode)
;Hide startup screen if started with file
(defun startup-screen-advice (orig-fun &rest args)
(when (= (seq-count #'buffer-file-name (buffer-list)) 0)
(apply orig-fun args)))
(advice-add 'display-startup-screen :around #'startup-screen-advice)
;Enable dashboard
(setq dashboard-center-content t)
(dashboard-setup-startup-hook)
(when (daemonp)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon
)
;CUA
(cua-mode 1)
(global-set-key (kbd "C-y") 'undo-redo)
;(define-key key-translation-map [8711] 'event-apply-hyper-modifier )
;(global-set-key (kbd "C-∇") (kbd "C-H"))
;(global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207)))

View File

@ -0,0 +1,8 @@
(straight-use-package 'use-package)
(straight-use-package 'telephone-line)
(straight-use-package 'elcord)
(straight-use-package 'dashboard)
(straight-use-package 'minions)
(straight-use-package 'moe-theme)