First nix-emacs config

This commit is contained in:
Aleksandr Lebedev 2025-01-27 19:56:46 +01:00
commit 173299ea8b
6 changed files with 226 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
eln-cache

29
config.org Normal file
View file

@ -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

79
flake.lock generated Normal file
View file

@ -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
}

45
flake.nix Normal file
View file

@ -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;
};
};
}

5
init.el Normal file
View file

@ -0,0 +1,5 @@
;;; -*- lexical-binding: t; -*-
(org-babel-load-file
(expand-file-name
"config.org"
user-emacs-directory))

67
package.nix Normal file
View file

@ -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 <package name>`.
# 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];
#});
};
}