From 7df5311859216128e3aa3d5720d0945a85bbca0f Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 10 Jun 2023 20:50:52 -0400 Subject: [PATCH] Setup room cleaning automation --- machines/pendulum/automation.nix | 36 +++++++++++++++++++++++++++++ machines/pendulum/configuration.nix | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 machines/pendulum/automation.nix diff --git a/machines/pendulum/automation.nix b/machines/pendulum/automation.nix new file mode 100644 index 0000000..5f2b099 --- /dev/null +++ b/machines/pendulum/automation.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: +let + path = with pkgs; [ jq postgresql_15 matrix-synapse-tools.synadm ]; + environment = { + HOME = "/home/nathan"; + XDG_CONFIG_DIRS = + "/etc/xdg:/home/nathan/.nix-profile/etc/xdg:/etc/profiles/per-user/nathan/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg"; + XDG_CONFIG_HOME = "/home/nathan/.config"; + }; + synapse-script = { name, script, schedule }: { + systemd.services."synapse-script-${name}" = { + inherit environment; + inherit path; + inherit script; + serviceConfig = { + Type = "oneshot"; + User = "nathan"; + Group = "users"; + }; + }; + systemd.timers."synapse-script-${name}" = { + wantedBy = [ "timers.target" ]; + partOf = [ "synapse-script-${name}.service" ]; + timerConfig = { + OnCalendar = schedule; + Unit = "synapse-script-${name}.service"; + }; + }; + }; +in lib.mkMerge [ + (synapse-script { + name = "clean-vacant-rooms"; + schedule = "23:00"; + script = builtins.readFile ../../scripts/matrix/clean-old-rooms.sh; + }) +] diff --git a/machines/pendulum/configuration.nix b/machines/pendulum/configuration.nix index 1bbefb8..dfa6031 100644 --- a/machines/pendulum/configuration.nix +++ b/machines/pendulum/configuration.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, inputs, ... }: { - imports = [ ./matrix.nix ]; + imports = [ ./matrix.nix ./automation.nix ]; # Sops setup for this machine sops.secrets = { "borg-ssh-key" = {