summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/deployment/events-publisher/default.nix
diff options
context:
space:
mode:
authorlassulus <lass@blue.r>2018-08-09 17:23:53 +0200
committerlassulus <lass@blue.r>2018-08-09 17:23:53 +0200
commit2bf24eae616997e52a16fff96b4485ee7c619f8d (patch)
treecbb3aab9f8fa2f4da28e5a01b16129263b1fa0cb /makefu/2configs/deployment/events-publisher/default.nix
parentf9d96d13de74ed6acbde92778af88f94f04081bd (diff)
parent6368507f02eb4e267c7fdab73e4c3cec5ee5827f (diff)
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs/deployment/events-publisher/default.nix')
-rw-r--r--makefu/2configs/deployment/events-publisher/default.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/makefu/2configs/deployment/events-publisher/default.nix b/makefu/2configs/deployment/events-publisher/default.nix
new file mode 100644
index 000000000..db8502c6e
--- /dev/null
+++ b/makefu/2configs/deployment/events-publisher/default.nix
@@ -0,0 +1,48 @@
+{ pkgs, ... }:
+with import <stockholm/lib>;
+let
+ shack-announce = pkgs.callPackage (builtins.fetchTarball {
+ url = "https://github.com/makefu/events-publisher/archive/15fbe5cc6ac9617a08a042870795f9e879d9952a.tar.gz";
+ sha256 = "1bqp1qdnwx5q1w468zbm57hmpjz3x8if3j29qrqcia0vzks1s37a";
+ }) {} ;
+ home = "/var/lib/shackannounce";
+ user = "shackannounce";
+ creds = (toString <secrets>) + "/shack-announce.json";
+in
+{
+ users.users.${user}= {
+ uid = genid user;
+ inherit home;
+ createHome = true;
+ };
+ systemd.services.shack-announce = {
+ description = "Announce shack events";
+ startAt = "*:0/30";
+ path = [ shack-announce ];
+ serviceConfig = {
+ WorkingDirectory = home;
+ User = user;
+ PermissionsStartOnly = true;
+ ExecStartPre = pkgs.writeDash "shack-announce-pre" ''
+ set -eu
+ cp ${creds} creds.json
+ chown ${user} creds.json
+ '';
+ ExecStart = pkgs.writeDash "shack-announce" ''
+ if test ! -e announce.state; then
+ echo "initializing state"
+ announce-daemon \
+ --lol INFO \
+ --creds creds.json \
+ --state announce.state \
+ --clean --init
+ fi
+ echo "Running announce"
+ announce-daemon \
+ --lol INFO \
+ --creds creds.json \
+ --state announce.state
+ '';
+ };
+ };
+}