Refactor codebase to use nix modules

This commit is contained in:
Julia Lange 2024-04-14 05:40:02 -07:00
parent a4735423b4
commit ffada2703c
114 changed files with 1018 additions and 744 deletions

View file

@ -0,0 +1,60 @@
{ config, pkgs, lib, ... }:
let rootPath = ./.; in
{
options.timer = {
enableHourly = lib.mkEnableOption "Enables an hourly notification";
enableQuarterly = lib.mkEnableOption "Enables a quarterly notification";
};
config = {
systemd.user.timers = {
hourly-time = lib.mkIf config.timer.enableHourly {
Timer = {
OnCalendar = "hourly";
};
Install = {
WantedBy = [
"timers.target"
];
};
};
quarterly-time = lib.mkIf config.timer.enableQuarterly {
Timer = {
OnCalendar = "*-*-* *:15,30,45:00";
};
Install = {
WantedBy = [
"timers.target"
];
};
};
};
systemd.user.services = {
hourly-time = lib.mkIf config.timer.enableHourly {
Unit = {
Description = "Notify the user every hour of time passing";
};
Service = {
Type="simple";
ExecStart="/home/pan/.config/timer_scripts/notify-time.sh 60000 1";
};
};
quarterly-time = lib.mkIf config.timer.enableQuarterly {
Unit = {
Description = "Notify the user every 15 minutes of time passing, \
skips hours";
};
Service = {
Type="simple";
ExecStart="/home/pan/.config/timer_scripts/notify-time.sh 10000 0";
};
};
};
xdg.configFile."timer-scripts" = {
source = rootPath + "/scripts";
target = "timer_scripts/";
executable = true;
};
};
}

Binary file not shown.

View file

@ -0,0 +1,8 @@
#!/bin/sh
export DISPLAY=":0"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
/home/pan/.nix-profile/bin/notify-send "$(/run/current-system/sw/bin/date +%H:%M)" -t $1
if [ $2 -eq 1 ]; then
/run/current-system/sw/bin/pw-cat --volume 0.08 -p ./chimes.ogg &
fi