citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

default.nix (1248B)


      1 extra:
      2 { config, lib, pkgs, ... }:
      3 let cfg = extra.private.vidstats;
      4     videostats = (import (pkgs.fetchgit {
      5       url    = "http://git.zero.jb55.com/edm-video-stats";
      6       rev    = "4514bd35d111257f71235fcb121cfbbc6c11eb15";
      7       sha256 = "0sd26vvffk12a3ax98qlcd0kw7lgnszx9lxyqfya913qkgcyrzmb";
      8     }) {}).package;
      9     client_secret = pkgs.fetchurl {
     10       name = "client_secret.json";
     11       url = "http://git.zero.jb55.com/repos/?p=edm-video-stats;a=blob_plain;f=client_secret.json";
     12       sha256 = "0i1kwq8zy1s1w7db3yh6687hyh44m5g5xrlxc425nfnl6hzl9187";
     13     };
     14 in
     15 {
     16   systemd.services.vidstats = {
     17     enable = true;
     18 
     19     description = "vidstats bot";
     20 
     21     wantedBy = [ "multi-user.target" ];
     22     after    = [ "network-online.target" ];
     23 
     24     environment = {
     25       GOOGLE_SHEET_ID = cfg.sheet_id;
     26       GOOGLE_API_KEY  = cfg.api_key;
     27       VIDEOSTATS_RANGE  = cfg.range;
     28       TOKEN_DIR = "/home/jb55/.config/edm/videostats/credentials";
     29       VIDEOSTATS_STATS_RANGE  = cfg.stats_range;
     30       CLIENT_SECRET = "${client_secret}";
     31     };
     32 
     33     serviceConfig.Type = "oneshot";
     34     serviceConfig.ExecStart = "${videostats}/bin/video-stats";
     35 
     36     unitConfig.OnFailure = "systemd-failure-emailer@%n.service";
     37 
     38     startAt = "*-*-* 05:24:00";
     39   };
     40 }