{ 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 { 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" ''; }; }; }