update to include java (eugh) and create a nixosModule

This commit is contained in:
Anish Lakhwara 2022-07-09 20:17:04 +10:00
parent 94097d905f
commit e5dc7d83b1

View file

@ -10,12 +10,39 @@
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
in in
{ {
nixosModule = { options, lib, config, pkgs, ... }:
let
serviceConfig = config.services.mossnet.dhyan;
options.enable = lib.mkEnableOption "Dhyan daily runner";
in
{
options.services.mossnet.dhyan = options;
config = lib.mkIf serviceConfig.enable {
systemd.services."dhyan" = {
description = ''
Various matrix bot integrations
'';
wantedBy = [ "multi-user.target" ];
serviceConfig = { Type = "oneshot"; };
startsAt = "*08:00:00";
path = with pkgs; [ babashka jdk11 ];
script = ''
set -ex
cd ~/usr/dhyan
bb -m dhyan.main
'';
};
};
};
devShell.x86_64-linux = pkgs.mkShell { devShell.x86_64-linux = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
jdk11
babashka babashka
]; ];
shellHook = '' shellHook = ''
[[ -z $token ]] && echo "::dhyan:: Necessary Env Var missing: token" [[ -z $SHAARLI_TOKEN ]] && echo "::dhyan:: Necessary Env Var missing: SHAARLI_TOKEN"
[[ -z $MATRIX_PASSWORD ]] && echo "::dhyan:: Necessary Env Var missing: MATRIX_PASSWORD"
[[ -z $folder ]] && echo "::dhyan:: Necessary Env Var missing: folder" [[ -z $folder ]] && echo "::dhyan:: Necessary Env Var missing: folder"
''; '';
}; };