just some boilerplate for the project

This commit is contained in:
stupidcomputer 2024-10-08 23:34:31 -05:00
parent 0f322fd358
commit 3e62ce8b08
7 changed files with 68 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix"
}

11
bridge/__init__.py Normal file
View File

@ -0,0 +1,11 @@
from flask import Flask
from flask import request
from flask import redirect
from flask import abort
app = Flask(__name__)
app.config.from_envvar('GIT_BRIDGE_SETTINGS')
@app.route("/bridge")
def index():
return "you've reached the main page for an internal service. congrats!"

1
contrib/sample.cfg Normal file
View File

@ -0,0 +1 @@
SECRET_KEY="replace_me"

19
contrib/service.nix Normal file
View File

@ -0,0 +1,19 @@
{ lib, pkgs, config, ... }:
let
cfg = config.services.gmail_mail_bridge;
appEnv = pkgs.python3.withPackages (p: with p; [ waitress (callPackage ./bridge/default.nix {}) ]);
in {
options.services.gmail_mail_bridge = {
enable = lib.mkEnableOption "Enable the Gitea-Github bridge";
};
config = lib.mkIf cfg.enable {
systemd.services.gmail_mail_bridge = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${appEnv}/bin/waitress-serve --port=8041 bridge:app";
StandardOutput = "journal";
};
};
};
}

20
default.nix Normal file
View File

@ -0,0 +1,20 @@
{ pkgs, pythonPackages ? (import <nixpkgs> {}).python3Packages }:
pythonPackages.buildPythonPackage {
name = "gitea-github-bridge";
src = ./bridge;
propagatedBuildInputs = [ pythonPackages.flask pythonPackages.requests ];
installPhase = ''
runHook preInstall
mkdir -p $out/${pythonPackages.python.sitePackages}
cp -r . $out/${pythonPackages.python.sitePackages}/bridge
runHook postInstall
'';
shellHook = "export FLASK_APP=bridge";
format = "other";
}

13
shell.nix Normal file
View File

@ -0,0 +1,13 @@
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05") {} }:
pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (ps: [
ps.flask
ps.requests
]))
pkgs.curl
pkgs.jq
];
}