enable daily browser summary on darwin

This commit is contained in:
Noah Masur
2026-01-25 10:42:53 -05:00
parent a64488093c
commit 430b522c61
3 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
{
config,
pkgs,
lib,
...
}:
let
inherit (config.nmasur.settings) username;
cfg = config.nmasur.presets.services.daily-summary;
process_urls = pkgs.writers.writePython3Bin "process-urls" {
libraries = [
pkgs.python3Packages.requests
pkgs.python3Packages.beautifulsoup4
];
} (builtins.readFile ./process-urls.py);
prompt = "Based on my browser usage for today from the markdown file located in /Users/${username}/Downloads/Sidebery/todays_urls.md, create or update a daily summary markdown file in the generated notes directory located in /Users/${username}/dev/personal/notes/generated/ with the filename format 'YYYY-MM-DD Daily Summary.md'. The resulting markdown file should use /Users/${username}/dev/personal/notes/templates/generated-summary.md as a format template, and it should summarize where I have spent my time today and highlight any notable links that I have visited. Please create markdown links to other relevant notes in /Users/${username}/dev/personal/notes/. If there is an existing markdown file for today, update it to include the newest information.";
in
{
options.nmasur.presets.services.daily-summary.enable = lib.mkEnableOption "Daily work summary";
config = lib.mkIf cfg.enable {
launchd.user.agents.daily-summary = {
# This replaces program and args entirely
script = ''
${process_urls}/bin/process-urls /Users/${username}/Downloads/Sidebery/
GEMINI_API_KEY=$(cat /Users/${username}/.config/gemini/.gemini_api_key) ${pkgs.gemini-cli}/bin/gemini --allowed-tools all --yolo --include-directories /Users/${username}/Downloads/Sidebery/ --include-directories /Users/${username}/dev/personal/notes/ "${prompt}"
'';
path = [
pkgs.bash
pkgs.coreutils
];
serviceConfig = {
Label = "com.example.daily-summary";
# Runs the script through /bin/sh automatically
# RunAtLoad = true;
StartCalendarInterval = [
{
Hour = 11;
Minute = 45;
}
{
Hour = 3;
Minute = 45;
}
{
Hour = 4;
Minute = 45;
}
{
Hour = 6;
Minute = 0;
}
{
Hour = 9;
Minute = 0;
}
{
Hour = 11;
Minute = 0;
}
];
};
};
};
}