mirror of
https://github.com/Ascyii/nixos.git
synced 2026-01-01 06:44:26 -05:00
59 lines
1.7 KiB
Nix
59 lines
1.7 KiB
Nix
{ pkgs, ... }:
|
|
|
|
{
|
|
# Experiments with services
|
|
systemd = {
|
|
timers."sync-manage-hourly" = {
|
|
enable = false;
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnBootSec = "10s"; # Start 10 seconds after boot
|
|
OnUnitActiveSec = "1h"; # Repeat every hour
|
|
Unit = "sync-manage.service"; # Points to the service unit
|
|
};
|
|
};
|
|
services = {
|
|
"shutdown-script" = {
|
|
enable = false;
|
|
description = "Run custom script on shutdown";
|
|
after = [ "shutdown.target" ]; # Ensure it runs during shutdown
|
|
script = "/home/jonas/projects/scripts/check_git.sh"; # Specify the path to your script
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "jonas"; # Run as jonas
|
|
WorkingDirectory = "/home/jonas"; # Set working directory to jonas' home
|
|
execStop = "/home/jonas/projects/scripts/check_git.sh"; # Specify the path to your script
|
|
# To ensure the script finishes before the system powers off
|
|
TimeoutStopSec = "30"; # You can adjust this if necessary
|
|
};
|
|
# To ensure the script finishes before the system powers off
|
|
};
|
|
"sync-manage" = {
|
|
script = ''
|
|
# Run the script from jonas' home directory
|
|
/home/jonas/projects/scripts/sync_manage.sh
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "jonas"; # Run as jonas
|
|
WorkingDirectory = "/home/jonas"; # Set working directory to jonas' home
|
|
};
|
|
};
|
|
"sync-manage-shutdown" = {
|
|
enable = false;
|
|
script = ''
|
|
# Check if the system is connected to Wi-Fi
|
|
/home/jonas/projects/scripts/sync_manage.sh
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "jonas"; # Run as jonas
|
|
ExecStop = "/usr/bin/true";
|
|
RemainAfterExit = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|