From 173299ea8b5c74be4ce43ff807dc695db1e7815a Mon Sep 17 00:00:00 2001 From: Aleksandr Lebedev Date: Mon, 27 Jan 2025 19:56:46 +0100 Subject: [PATCH] First nix-emacs config --- .gitignore | 1 + config.org | 29 ++++++++++++++++++++ flake.lock | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 45 ++++++++++++++++++++++++++++++ init.el | 5 ++++ package.nix | 67 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 226 insertions(+) create mode 100644 .gitignore create mode 100644 config.org create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 init.el create mode 100644 package.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dc84e3a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +eln-cache diff --git a/config.org b/config.org new file mode 100644 index 0000000..2fdf198 --- /dev/null +++ b/config.org @@ -0,0 +1,29 @@ +#+TITLE: KyleKrein's GNU Emacs Config +#+STARTUP: showeverything +#+OPTIONS: toc:2 +#+PROPERTY: header-args:emacs-lisp :lexical t + + +* IMPORTANT PROGRAMS TO LOAD FIRST +** Lexical Binding (MUST BE FIRST) +#+begin_src emacs-lisp +#+end_src +** Evil Mode +#+begin_src emacs-lisp :lexical t +(use-package evil + :ensure t + :init ;; tweak evil's configuration before loading it + (setq evil-want-integration t) ;; This is optional since it's already set to t by default. + (setq evil-want-keybinding nil) + (setq evil-vsplit-window-right t) + (setq evil-split-window-below t) + (evil-mode)) + (use-package evil-collection + :ensure t + :after evil + :config + (setq evil-collection-mode-list '(dashboard dired ibuffer)) + (evil-collection-init)) + (use-package evil-tutor + :ensure t) +#+end_src diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9cc395e --- /dev/null +++ b/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "emacs-overlay": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1737998189, + "narHash": "sha256-Np3e0z3S9nSbnbqaj+i0KyCR5S+KS+bdqHyser+KJuU=", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "2251b6ce66de3f27aaf26779f2dc8c7b99402014", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "emacs-overlay", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1737885589, + "narHash": "sha256-Zf0hSrtzaM1DEz8//+Xs51k/wdSajticVrATqDrfQjg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "852ff1d9e153d8875a83602e03fdef8a63f0ecf8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1737885640, + "narHash": "sha256-GFzPxJzTd1rPIVD4IW+GwJlyGwBDV1Tj5FLYwDQQ9sM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4e96537f163fad24ed9eb317798a79afc85b51b7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1737885589, + "narHash": "sha256-Zf0hSrtzaM1DEz8//+Xs51k/wdSajticVrATqDrfQjg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "852ff1d9e153d8875a83602e03fdef8a63f0ecf8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "emacs-overlay": "emacs-overlay", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b632c25 --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +{ + description = "KyleKrein's emacs flake configuration"; + + nixConfig = { + extra-substituters = ["https://nix-community.cachix.org"]; + extra-trusted-public-keys = ["nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="]; + }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + emacs-overlay.url = "github:nix-community/emacs-overlay"; + }; + + outputs = { + self, + nixpkgs, + emacs-overlay, + }: { + packages.x86_64-linux.default = import ./package.nix { + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [emacs-overlay.overlays.default]; + }; + }; + packages.aarch64-linux.default = import ./package.nix { + pkgs = import nixpkgs { + system = "aarch64-linux"; + overlays = [emacs-overlay.overlays.default]; + }; + }; + packages.x86_64-linux.x11 = import ./package.nix { + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [emacs-overlay.overlays.default]; + }; + x11 = true; + }; + packages.aarch64-linux.x11 = import ./package.nix { + pkgs = import nixpkgs { + system = "aarch64-linux"; + overlays = [emacs-overlay.overlays.default]; + }; + x11 = true; + }; + }; +} diff --git a/init.el b/init.el new file mode 100644 index 0000000..41ab4c1 --- /dev/null +++ b/init.el @@ -0,0 +1,5 @@ +;;; -*- lexical-binding: t; -*- +(org-babel-load-file + (expand-file-name + "config.org" + user-emacs-directory)) diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..dc5fa1a --- /dev/null +++ b/package.nix @@ -0,0 +1,67 @@ +{ + pkgs, + x11 ? false, + ... +}: let + emacs = + if x11 + then pkgs.emacs-unstable + else pkgs.emacs-pgtk; +in + pkgs.emacsWithPackagesFromUsePackage { + # Your Emacs config file. Org mode babel files are also + # supported. + # NB: Config files cannot contain unicode characters, since + # they're being parsed in nix, which lacks unicode + # support. + # config = ./emacs.org; + config = ./config.org; + + # Whether to include your config as a default init file. + # If being bool, the value of config is used. + # Its value can also be a derivation like this if you want to do some + # substitution: + # defaultInitFile = pkgs.substituteAll { + # name = "default.el"; + # src = ./emacs.el; + # inherit (config.xdg) configHome dataHome; + # }; + defaultInitFile = pkgs.substituteAll { + name = "default.el"; + src = ./init.el; + }; + + # Package is optional, defaults to pkgs.emacs + package = emacs; + + # By default emacsWithPackagesFromUsePackage will only pull in + # packages with `:ensure`, `:ensure t` or `:ensure `. + # Setting `alwaysEnsure` to `true` emulates `use-package-always-ensure` + # and pulls in all use-package references not explicitly disabled via + # `:ensure nil` or `:disabled`. + # Note that this is NOT recommended unless you've actually set + # `use-package-always-ensure` to `t` in your config. + alwaysEnsure = false; + + # For Org mode babel files, by default only code blocks with + # `:tangle yes` are considered. Setting `alwaysTangle` to `true` + # will include all code blocks missing the `:tangle` argument, + # defaulting it to `yes`. + # Note that this is NOT recommended unless you have something like + # `#+PROPERTY: header-args:emacs-lisp :tangle yes` in your config, + # which defaults `:tangle` to `yes`. + alwaysTangle = true; + + # Optionally provide extra packages not in the configuration file. + # This can also include extra executables to be run by Emacs (linters, + # language servers, formatters, etc) + extraEmacsPackages = epkgs: [ + ]; + + # Optionally override derivations. + override = final: prev: { + #weechat = prev.melpaPackages.weechat.overrideAttrs (old: { + # patches = [./weechat-el.patch]; + #}); + }; + }