|
3 | 3 | inputs = { |
4 | 4 | nixpkgs.url = "nixpkgs/nixos-unstable"; |
5 | 5 | flake-utils.url = "github:numtide/flake-utils"; |
6 | | - poetry2nix.url = "github:nix-community/poetry2nix"; |
| 6 | + pyproject-nix = { |
| 7 | + url = "github:pyproject-nix/pyproject.nix"; |
| 8 | + inputs.nixpkgs.follows = "uv2nix/nixpkgs"; |
| 9 | + # inputs.uv2nix.follows = "nixpkgs"; |
| 10 | + }; |
| 11 | + pyproject-build-systems = { |
| 12 | + url = "github:pyproject-nix/build-system-pkgs"; |
| 13 | + inputs.pyproject-nix.follows = "pyproject-nix"; |
| 14 | + inputs.uv2nix.follows = "uv2nix"; |
| 15 | + inputs.nixpkgs.follows = "uv2nix/nixpkgs"; |
| 16 | + # inputs.uv2nix.follows = "nixpkgs"; |
| 17 | + }; |
| 18 | + uv2nix = { |
| 19 | + url = "github:pyproject-nix/uv2nix"; |
| 20 | + inputs.pyproject-nix.follows = "pyproject-nix"; |
| 21 | + # stale nixpkgs is missing the alias `lib.match` -> `builtins.match` |
| 22 | + # therefore point uv2nix to a patched nixpkgs, which introduces this alias |
| 23 | + # this is a temporary solution until nixpkgs us up-to-date again |
| 24 | + inputs.nixpkgs.url = "github:runtimeverification/nixpkgs/libmatch"; |
| 25 | + # inputs.uv2nix.follows = "nixpkgs"; |
| 26 | + }; |
7 | 27 | }; |
8 | | - outputs = { self, nixpkgs, flake-utils, poetry2nix }: |
9 | | - let |
10 | | - allOverlays = [ |
11 | | - poetry2nix.overlay |
12 | | - (final: prev: { |
13 | | - {{ cookiecutter.project_slug }} = prev.poetry2nix.mkPoetryApplication { |
14 | | - python = prev.python310; |
15 | | - projectDir = ./.; |
16 | | - groups = []; |
17 | | - # We remove `dev` from `checkGroups`, so that poetry2nix does not try to resolve dev dependencies. |
18 | | - checkGroups = []; |
19 | | - }; |
20 | | - }) |
21 | | - ]; |
22 | | - in flake-utils.lib.eachSystem [ |
| 28 | + outputs = { self, nixpkgs, flake-utils, pyproject-nix, pyproject-build-systems, uv2nix }: |
| 29 | + let |
| 30 | + pythonVer = "310"; |
| 31 | + in flake-utils.lib.eachSystem [ |
23 | 32 | "x86_64-linux" |
24 | 33 | "x86_64-darwin" |
25 | 34 | "aarch64-linux" |
26 | 35 | "aarch64-darwin" |
27 | 36 | ] (system: |
28 | | - let |
29 | | - pkgs = import nixpkgs { |
30 | | - inherit system; |
31 | | - overlays = allOverlays; |
| 37 | + let |
| 38 | + # due to the nixpkgs that we use in this flake being outdated, uv is also heavily outdated |
| 39 | + # we can instead use the binary release of uv provided by uv2nix for now |
| 40 | + uvOverlay = final: prev: { |
| 41 | + uv = uv2nix.packages.${final.system}.uv-bin; |
| 42 | + }; |
| 43 | + {{ cookiecutter.project_slug }}Overlay = final: prev: { |
| 44 | + {{ cookiecutter.project_slug }} = final.callPackage ./nix/{{ cookiecutter.project_slug }} { |
| 45 | + inherit pyproject-nix pyproject-build-systems uv2nix; |
| 46 | + python = final."python${pythonVer}"; |
32 | 47 | }; |
33 | | - in { |
34 | | - packages = rec { |
35 | | - inherit (pkgs) {{ cookiecutter.project_slug }}; |
36 | | - default = {{ cookiecutter.project_slug }}; |
| 48 | + }; |
| 49 | + pkgs = import nixpkgs { |
| 50 | + inherit system; |
| 51 | + overlays = [ |
| 52 | + uvOverlay |
| 53 | + {{ cookiecutter.project_slug }}Overlay |
| 54 | + ]; |
| 55 | + }; |
| 56 | + python = pkgs."python${pythonVer}"; |
| 57 | + in { |
| 58 | + devShells.default = pkgs.mkShell { |
| 59 | + name = "uv develop shell"; |
| 60 | + buildInputs = [ |
| 61 | + python |
| 62 | + pkgs.uv |
| 63 | + ]; |
| 64 | + env = { |
| 65 | + # prevent uv from managing Python downloads and force use of specific |
| 66 | + UV_PYTHON_DOWNLOADS = "never"; |
| 67 | + UV_PYTHON = python.interpreter; |
37 | 68 | }; |
38 | | - }) // { |
39 | | - overlay = nixpkgs.lib.composeManyExtensions allOverlays; |
| 69 | + shellHook = '' |
| 70 | + unset PYTHONPATH |
| 71 | + ''; |
| 72 | + }; |
| 73 | + packages = rec { |
| 74 | + inherit (pkgs) {{ cookiecutter.project_slug }}; |
| 75 | + default = {{ cookiecutter.project_slug }}; |
| 76 | + }; |
| 77 | + }) // { |
| 78 | + overlays.default = final: prev: { |
| 79 | + inherit (self.packages.${final.system}) {{ cookiecutter.project_slug }}; |
40 | 80 | }; |
| 81 | + }; |
41 | 82 | } |
0 commit comments