Files
lux/modules/capabilities/notes.nix
T

82 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}}
'';
openDailyNote = pkgs.writeShellApplication {
name = "open-daily-note";
text = ''
exec ${lib.getExe config.programs.kitty.package} --detach \
--directory "${home}/sync/notes" \
${lib.getExe pkgs.zsh} -lic 'zk daily'
'';
};
in
{
home.packages = [
openDailyNote
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" \
"${home}/sync/recordings/inbox" \
"${home}/sync/recordings/processing" \
"${home}/sync/recordings/archive" \
"${home}/sync/recordings/failed"
'';
};
flake.modules.nixos.notes =
{ ... }:
{
home-manager.sharedModules = [ homeModules.notes ];
};
}