Files
lux/modules/capabilities/notes.nix
T
2026-09-22 21:44:35 +02:00

86 lines
2.0 KiB
Nix

{ config, ... }:
let
homeModules = config.flake.modules.homeManager;
in
{
flake.modules.homeManager.notes =
{
config,
lib,
pkgs,
...
}:
let
home = config.home.homeDirectory;
zkConfig = ''
[note]
filename = "{{format-date now 'timestamp'}}-{{slug title}}"
template = "default.md"
[tool]
fzf-preview = "bat --plain --color=always {-1}"
[group.daily]
paths = ["daily"]
[group.daily.note]
filename = "{{format-date now '%Y-%m-%d'}}"
extension = "md"
template = "daily.md"
[alias]
daily = 'nvim + "$(zk new --no-input --print-path "$ZK_NOTEBOOK_DIR/daily")"'
'';
noteTemplate = ''
---
date: {{format-date now}}
---
# {{title}}
'';
openNotes = pkgs.writeShellApplication {
name = "open-notes";
text = ''
exec ${lib.getExe config.programs.kitty.package} --detach \
--directory "${home}/sync/notes" \
nvim '+autocmd VimEnter * ++once ZkNotes'
'';
};
in
{
home.packages = [
openNotes
(pkgs.makeDesktopItem {
name = "notes";
desktopName = "Notes";
icon = "text-editor";
exec = lib.getExe openNotes;
path = "${home}/sync/notes";
terminal = false;
})
pkgs.ripgrep-all
pkgs.zk
];
home.file = {
"sync/notes/.zk/config.toml".text = zkConfig;
"sync/notes/.zk/templates/daily.md".text = "";
"sync/notes/.zk/templates/default.md".text = noteTemplate;
};
home.activation.createNotesLayout = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
${pkgs.coreutils}/bin/mkdir -p \
"${home}/sync/notes/daily" \
"${home}/sync/notes/meetings" \
"${home}/sync/notes/transcripts"
'';
};
flake.modules.nixos.notes =
{ ... }:
{
home-manager.sharedModules = [ homeModules.notes ];
};
}