|
1 | 1 | { |
2 | 2 | inputs = { |
3 | 3 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
4 | | - poetry2nix = { |
5 | | - url = "github:nix-community/poetry2nix"; |
6 | | - inputs.nixpkgs.follows = "nixpkgs"; |
7 | | - }; |
8 | 4 | flake-parts.url = "github:hercules-ci/flake-parts"; |
9 | 5 | flake-utils.url = "github:numtide/flake-utils"; |
10 | 6 | process-compose-flake.url = "github:Platonic-Systems/process-compose-flake"; |
|
37 | 33 | ... |
38 | 34 | }: |
39 | 35 | let |
40 | | - poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }; |
41 | | - python = pkgs.python312; |
42 | | - overrides = poetry2nix.defaultPoetryOverrides.extend ( |
43 | | - self: super: { |
44 | | - types-peewee = super.types-peewee.overridePythonAttrs (old: { |
45 | | - buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; |
46 | | - }); |
47 | | - types-markupsafe = super.types-markupsafe.overridePythonAttrs (old: { |
48 | | - buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; |
49 | | - }); |
50 | | - types-werkzeug = super.types-werkzeug.overridePythonAttrs (old: { |
51 | | - buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; |
52 | | - }); |
53 | | - types-jinja2 = super.types-jinja2.overridePythonAttrs (old: { |
54 | | - buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; |
55 | | - }); |
56 | | - types-flask = super.types-flask.overridePythonAttrs (old: { |
57 | | - buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; |
58 | | - }); |
59 | | - } |
60 | | - ); |
61 | | - application = poetry2nix.mkPoetryApplication { |
62 | | - projectDir = ./.; |
63 | | - inherit overrides; |
64 | | - inherit python; |
65 | | - }; |
66 | | - env = poetry2nix.mkPoetryEnv { |
67 | | - projectDir = ./.; |
68 | | - groups = [ "dev" ]; |
69 | | - editablePackageSources = { |
70 | | - snapbin = ./snapbin; |
| 36 | + pyproject = pkgs.lib.importTOML ./pyproject.toml; |
| 37 | + myPython = pkgs.python312.override { |
| 38 | + self = myPython; |
| 39 | + packageOverrides = pyfinal: pyprev: { |
| 40 | + # An editable package with a script that loads our mutable location |
| 41 | + snapbin-editable = pyfinal.mkPythonEditablePackage { |
| 42 | + # Inherit project metadata from pyproject.toml |
| 43 | + pname = pyproject.project.name; |
| 44 | + inherit (pyproject.project) version; |
| 45 | + |
| 46 | + # The editable root passed as a string |
| 47 | + root = "$DEVENV_ROOT/snapbin"; # Use environment variable expansion at runtime |
| 48 | + }; |
71 | 49 | }; |
72 | | - inherit overrides; |
73 | | - inherit python; |
74 | 50 | }; |
| 51 | + |
| 52 | + pythonDev = myPython.withPackages (p: [ |
| 53 | + p.black |
| 54 | + p.gunicorn |
| 55 | + p.isort |
| 56 | + p.snapbin-editable |
| 57 | + p.mypy |
| 58 | + p.pylint |
| 59 | + p.pylsp-mypy |
| 60 | + p.pytest |
| 61 | + p.pytest-cov |
| 62 | + p.pytest-xdist |
| 63 | + p.python-lsp-ruff |
| 64 | + p.python-lsp-server |
| 65 | + p.ruff |
| 66 | + ]); |
| 67 | + pythonProd = myPython.withPackages (p: [ |
| 68 | + p.gunicorn |
| 69 | + p.snapbin-editable |
| 70 | + ]); |
75 | 71 | in |
76 | 72 | { |
77 | 73 | process-compose."dev-services" = { |
|
85 | 81 | settings.processes.gunicorn = { |
86 | 82 | command = '' |
87 | 83 | cd "$DEVENV_ROOT" |
88 | | - ${application.dependencyEnv}/bin/gunicorn --bind=0.0.0.0 snapbin.main:app |
| 84 | + ${pythonDev}/bin/gunicorn --bind=0.0.0.0 snapbin.main:app |
89 | 85 | ''; |
90 | 86 | }; |
91 | 87 | } |
|
97 | 93 | tag = "latest"; |
98 | 94 | copyToRoot = pkgs.buildEnv { |
99 | 95 | name = "image-root"; |
100 | | - paths = [ application.dependencyEnv ]; |
| 96 | + paths = [ pythonProd ]; |
101 | 97 | }; |
102 | 98 | config = { |
103 | 99 | Cmd = [ |
104 | | - "${application.dependencyEnv}/bin/gunicorn" |
| 100 | + "${pythonProd}/bin/gunicorn" |
105 | 101 | "--bind=0.0.0.0" |
106 | 102 | "snapbin.main:app" |
107 | 103 | ]; |
|
124 | 120 | PC_PORT_NUM = "9999"; |
125 | 121 | }; |
126 | 122 | packages = [ |
127 | | - env |
| 123 | + pythonDev |
128 | 124 | pkgs.poetry |
129 | 125 | ]; |
130 | 126 | inputsFrom = [ |
|
0 commit comments