dhyan/flake.nix
Anish Lakhwara 8fc5e4bc3c fix: bug which wasn't actually getting all shaarli requests, turns out
shaarli's api has limit: all which negates the need to do what i was
doing
2022-08-30 21:33:53 +10:00

83 lines
2.6 KiB
Nix

{
description = "An album of the day chooser";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = { self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
{
packages.x86_64-linux.dhyan = pkgs.stdenv.mkDerivation {
name = "dhyan";
src = ./.;
installPhase = ''
mkdir -p $out
cp -r src/ $out/
cp bb.edn $out/
cp deps.edn $out/
'';
};
defaultPackage.x86_64-linux = self.packages.x86_64-linux.dhyan;
nixosModule = { options, lib, config, pkgs, ... }:
let
serviceConfig = config.services.mossnet.dhyan;
options.enable = lib.mkEnableOption "Dhyan daily runner";
in
{
# TODO This won't work either because secrets aren't passed
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"; };
startAt = "*08:00:00";
path = with pkgs; [ babashka jdk11 self.packages.x86_64-linux.dhyan ];
script = ''
set -ex
cd ${self.packages.x86_64-linux.dhyan}
bb -m dhyan.main
'';
};
};
};
nixosConfigurations."test" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModule
({ pkgs, ... }: {
boot.isContainer = true;
networking.hostName = "dhyan";
services.mossnet.dhyan.enable = true;
# we need network to download java deps handled by bb
# but we also need to tell network manager locally not to manage this interface
# TODO
# networking.nat.enable = true;
# networking.nat.internalInterfaces = [ "ve-+" ];
# networking.nat.externalInterface = "wlp3s0"; # Change this if it changes
})
];
};
devShell.x86_64-linux = pkgs.mkShell {
buildInputs = with pkgs; [
jdk11
babashka
];
shellHook = ''
[[ -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"
'';
};
};
}