add nix support

This commit is contained in:
Yann Esposito (Yogsototh) 2022-09-11 18:26:49 +02:00
parent fe3bd7ec78
commit eb11703fa5
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
9 changed files with 61 additions and 2 deletions

4
app.py
View file

@ -63,4 +63,6 @@ def supported_websites():
return render_template('supported.html', sites=sites)
if __name__ == '__main__':
app.run('localhost', 8080, debug=True, threaded=True)
from waitress import serve
serve(app, host='127.0.0.1', port=41011)
# app.run('localhost', 8080, debug=True, threaded=True)

1
nix/default.nix Normal file
View file

@ -0,0 +1 @@
import ./shell.nix

18
nix/inputs.nix Normal file
View file

@ -0,0 +1,18 @@
with builtins;
let
lock = fromTOML (readFile ./lock.toml);
in rec {
pkgs = import (builtins.fetchTarball {
name = "nixpkgs";
url = "https://github.com/nixos/nixpkgs/tarball/${lock.nixpkgs.rev}";
sha256 = "${lock.nixpkgs.sha256}";
}) { config = {}; overlays = []; };
mach-nix = import (builtins.fetchTarball {
url = "https://github.com/DavHau/mach-nix/tarball/${lock.mach-nix.rev}";
sha256 = lock.mach-nix.sha256;
}) {
python = "python39";
inherit pkgs;
};
}

9
nix/lock.toml Normal file
View file

@ -0,0 +1,9 @@
[mach-nix]
ref = "master"
rev = "65266b5cc867fec2cb6a25409dd7cd12251f6107"
sha256 = "1zavy2d4nmb5c05gb91xgwc2gqqch0y6d1y7mwldxwyr3ja43q6l"
[nixpkgs]
ref = "554d2d8aa25b6e583575459c297ec23750adb6cb"
rev = "554d2d8aa25b6e583575459c297ec23750adb6cb"
sha256 = "01yfqslnkyrfb5yjfablhvw830iw0za3mab4n03a0ldyq5ac6wh1"

5
nix/python.nix Normal file
View file

@ -0,0 +1,5 @@
with (import ./inputs.nix);
mach-nix.mkPython {
requirements = builtins.readFile ./requirements.txt;
}

6
nix/requirements.txt Normal file
View file

@ -0,0 +1,6 @@
flask==2.1.0
recipe-scrapers==14.13.0
beautifulsoup4
requests
Gunicorn
waitress

8
nix/shell.nix Normal file
View file

@ -0,0 +1,8 @@
with (import ./inputs.nix);
pkgs.mkShell {
buildInputs = [
(import ./python.nix)
mach-nix.mach-nix
];
}

View file

@ -2,4 +2,5 @@ flask==2.1.0
recipe-scrapers==14.13.0
beautifulsoup4
requests
Gunicorn
Gunicorn
waitress

9
start.sh Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env zsh
# Prerequiste
# nix shell github:DavHau/mach-nix
# mach-nix env ./env -r requirements.txt
# nix-shell ./env
cd $0:h
nix-shell ./nix --command "python app.py"