Create own flake for emacs

This commit is contained in:
Tobias Ostner 2025-04-21 17:53:35 +02:00
parent 75be932b45
commit 98c77fe32e
11 changed files with 174 additions and 129 deletions

32
flake.lock generated
View file

@ -20,6 +20,25 @@
"type": "github" "type": "github"
} }
}, },
"emacs-config": {
"inputs": {
"home-manager": [
"home-manager"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"path": "./flakes/emacs",
"type": "path"
},
"original": {
"path": "./flakes/emacs",
"type": "path"
},
"parent": []
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -27,11 +46,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1744600951, "lastModified": 1745205007,
"narHash": "sha256-LNAAfQTDXSwtYYlh/v/tMwnCqeQAEHlBC9PgyQK5b/Q=", "narHash": "sha256-k67bEcLkSo13TIBfs0CGYkJjG12aaikabMtxWbSeqr0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "e980d0e0e216f527ea73cfd12c7b019eceffa7f1", "rev": "3fbe9a2b76ff5c4dcb2a2a2027dac31cfc993c8c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -42,11 +61,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1744463964, "lastModified": 1744932701,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=", "narHash": "sha256-fusHbZCyv126cyArUwwKrLdCkgVAIaa/fQJYFlCEqiU=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650", "rev": "b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -59,6 +78,7 @@
"root": { "root": {
"inputs": { "inputs": {
"darwin": "darwin", "darwin": "darwin",
"emacs-config": "emacs-config",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }

View file

@ -5,6 +5,11 @@
home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/"; home-manager.url = "github:nix-community/home-manager/";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
emacs-config = {
url = "path:./flakes/emacs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
}; };
outputs = inputs: outputs = inputs:
@ -13,11 +18,14 @@
in in
{ {
darwinConfigurations = { darwinConfigurations = {
TobAir = darwin-system { TobBook = darwin-system {
system = "aarch64-darwin"; system = "aarch64-darwin";
username = "tobi"; username = "tobi";
email = "tobias.ostner@gmail.com"; email = "tobias.ostner@gmail.com";
hostname = "TobAir"; hostname = "TobBook";
extraHomeManagerModules = [
inputs.emacs-config.homeManagerModules.aarch64-darwin
];
}; };
TobWork = darwin-system { TobWork = darwin-system {
system = "aarch64-darwin"; system = "aarch64-darwin";
@ -25,12 +33,6 @@
email = "tobias.ostner@jambit.com"; email = "tobias.ostner@jambit.com";
hostname = "laptop1042"; hostname = "laptop1042";
}; };
TobBook = darwin-system {
system = "aarch64-darwin";
username = "tobi";
email = "tobias.ostner@gmail.com";
hostname = "TobBook";
};
}; };
}; };
} }

View file

@ -257,12 +257,14 @@
(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
(add-hook 'package-menu-mode-hook #'hl-line-mode) (add-hook 'package-menu-mode-hook #'hl-line-mode)
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(add-hook 'enable-theme-functions ;; TODO: symbols function definition is void
(lambda (&rest _args) ;; (add-hook 'enable-theme-functions
(set-face-attribute ;; (lambda (&rest _args)
'tab-bar nil ;; (set-face-attribute
:box `(:line-width 4 :color ,(modus-themes-get-color-value 'bg-main)) ;; 'tab-bar nil
:background (modus-themes-get-color-value 'bg-main))))) ;; :box `(:line-width 4 :color ,(modus-themes-get-color-value 'bg-main))
;; :background (modus-themes-get-color-value 'bg-main))))
)
(use-package envrc (use-package envrc
:config :config

14
flakes/emacs/flake.nix Normal file
View file

@ -0,0 +1,14 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager/";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs:
{
homeManagerModules = {
aarch64-darwin = import ./home.nix;
};
};
}

108
flakes/emacs/home.nix Normal file
View file

@ -0,0 +1,108 @@
{ config, pkgs, lib, ... }:
{
home.file.".emacs.d/early-init.el".source = ./config/early-init.el;
home.file.".emacs.d/tree-sitter/libtree-sitter-swift.dylib".source = ./config/tree-sitter/libtree-sitter-swift.dylib;
home.file.".emacs.d/snippets".source = ./config/snippets;
programs.emacs = {
enable = true;
extraConfig = builtins.readFile ./config/init.el +
builtins.readFile ./config/lisp/utils.el;
extraPackages = epkgs: (with epkgs; [
ace-window
apheleia
avy
cape
cider
clojure-mode
consult
(trivialBuild {
pname = "copilot";
version = "master-12-28-2024";
src = pkgs.fetchFromGitHub {
owner = "copilot-emacs";
repo = "copilot.el";
rev = "c5dfa99f05878db5e6a6a378dc7ed09f11e803d4";
hash = "sha256-FzI08AW7a7AleEM7kSQ8LsWsDYID8SW1SmSN6/mIB/A=";
};
packageRequires = [
editorconfig
dash
f
jsonrpc
];
})
corfu
diff-hl
dockerfile-mode
ef-themes
eglot
envrc
exec-path-from-shell
flycheck
flycheck-clj-kondo
flycheck-swiftlint
(trivialBuild {
pname = "gptel";
version = "master-09-29-2024";
src = pkgs.fetchFromGitHub {
owner = "karthink";
repo = "gptel";
rev = "2b9398a7b3bb2a66f52a8d0b1fdc3f311b2c1a3d";
hash = "sha256-+CxSA9QmyKigbk8kB5N6kKZ/a5Tw0X4ym57AOoqYA4Y=";
};
})
graphql-mode
helpful
htmlize
jinx
js2-mode
json-mode
ligature
minions
multiple-cursors
nerd-icons
nerd-icons-completion
nerd-icons-corfu
nerd-icons-dired
nerd-icons-ibuffer
ob-restclient
ob-swift
olivetti
orderless
org
org-modern
ox-gfm
ox-reveal
pulsar
rainbow-delimiters
rainbow-mode
restclient
smartparens
swift-mode
(trivialBuild {
pname = "swift-ts-mode";
version = "main-07-05-2024";
src = pkgs.fetchFromGitHub {
owner = "rechsteiner";
repo = "swift-ts-mode";
rev = "5e198d306bd4d49e4dddab39195fe99e1caf8892";
hash = "sha256-c7AAFuaDbufMpzJtJ2PbRRXFJmo1y4L50T0idzxrvao=";
};
})
super-save
treesit-auto
ob-typescript
yaml-mode
vterm
fontaine
magit
magit-todos
marginalia
modus-themes
nix-mode
vertico
yasnippet
]);
};
}

View file

@ -1,7 +1,4 @@
{ email }: { pkgs, ... }: { { email }: { pkgs, ... }: {
home.file.".emacs.d/early-init.el".source = ../config/emacs/early-init.el;
home.file.".emacs.d/tree-sitter/libtree-sitter-swift.dylib".source = ../config/emacs/tree-sitter/libtree-sitter-swift.dylib;
home.file.".emacs.d/snippets".source = ../config/emacs/snippets;
home.file.".clojure/deps.edn".source = ../config/clojure/deps.edn; home.file.".clojure/deps.edn".source = ../config/clojure/deps.edn;
@ -69,108 +66,6 @@
nix-direnv.enable = true; nix-direnv.enable = true;
}; };
emacs = {
enable = true;
extraConfig = builtins.readFile ../config/emacs/init.el +
builtins.readFile ../config/emacs/lisp/utils.el;
extraPackages = epkgs: (with epkgs; [
ace-window
apheleia
avy
cape
cider
clojure-mode
consult
(trivialBuild {
pname = "copilot";
version = "master-12-28-2024";
src = pkgs.fetchFromGitHub {
owner = "copilot-emacs";
repo = "copilot.el";
rev = "c5dfa99f05878db5e6a6a378dc7ed09f11e803d4";
hash = "sha256-FzI08AW7a7AleEM7kSQ8LsWsDYID8SW1SmSN6/mIB/A=";
};
packageRequires = [
editorconfig
dash
f
jsonrpc
];
})
corfu
diff-hl
dockerfile-mode
ef-themes
eglot
envrc
exec-path-from-shell
flycheck
flycheck-clj-kondo
flycheck-swiftlint
(trivialBuild {
pname = "gptel";
version = "master-09-29-2024";
src = pkgs.fetchFromGitHub {
owner = "karthink";
repo = "gptel";
rev = "2b9398a7b3bb2a66f52a8d0b1fdc3f311b2c1a3d";
hash = "sha256-+CxSA9QmyKigbk8kB5N6kKZ/a5Tw0X4ym57AOoqYA4Y=";
};
})
graphql-mode
helpful
htmlize
jinx
js2-mode
json-mode
ligature
minions
multiple-cursors
nerd-icons
nerd-icons-completion
nerd-icons-corfu
nerd-icons-dired
nerd-icons-ibuffer
ob-restclient
ob-swift
olivetti
orderless
org
org-modern
ox-gfm
ox-reveal
pulsar
rainbow-delimiters
rainbow-mode
restclient
smartparens
swift-mode
(trivialBuild {
pname = "swift-ts-mode";
version = "main-07-05-2024";
src = pkgs.fetchFromGitHub {
owner = "rechsteiner";
repo = "swift-ts-mode";
rev = "5e198d306bd4d49e4dddab39195fe99e1caf8892";
hash = "sha256-c7AAFuaDbufMpzJtJ2PbRRXFJmo1y4L50T0idzxrvao=";
};
})
super-save
treesit-auto
ob-typescript
yaml-mode
vterm
fontaine
magit
magit-todos
marginalia
modus-themes
nix-mode
vertico
yasnippet
]);
};
fzf = { fzf = {
enable = true; enable = true;
enableZshIntegration = true; enableZshIntegration = true;

View file

@ -4,10 +4,11 @@
, username , username
, email , email
, hostname , hostname
, extraHomeManagerModules ? [ ]
}: }:
let let
system-config = import ../module/configuration.nix { inherit hostname; }; systemConfig = import ../module/configuration.nix { inherit hostname; };
home-manager-config = import ../module/home-manager.nix { inherit email; }; homeManagerConfig = import ../module/home-manager.nix { inherit email; };
in in
inputs.darwin.lib.darwinSystem { inputs.darwin.lib.darwinSystem {
inherit system; inherit system;
@ -17,13 +18,16 @@ inputs.darwin.lib.darwinSystem {
users.users.${username}.home = "/Users/${username}"; users.users.${username}.home = "/Users/${username}";
} }
system-config systemConfig
inputs.home-manager.darwinModules.home-manager inputs.home-manager.darwinModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users."${username}" = home-manager-config; home-manager.users."${username}" =
inputs.nixpkgs.lib.modules.mkMerge (
[ homeManagerConfig ] ++ extraHomeManagerModules
);
home-manager.backupFileExtension = "backup"; home-manager.backupFileExtension = "backup";
} }
]; ];