flake: Convert to uv2nix

This commit is contained in:
OatmealDome
2025-08-21 23:49:00 +00:00
committed by OatmealDome
parent be3ca8b0b0
commit c14c60b18e

View File

@@ -3,32 +3,53 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
inputs.poetry2nix.url = "github:nix-community/poetry2nix";
inputs.poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-utils, poetry2nix }: {
overlay = nixpkgs.lib.composeManyExtensions [
poetry2nix.overlays.default
(final: prev: {
netplay-index = prev.poetry2nix.mkPoetryApplication {
projectDir = ./.;
checkPhase = "GEOIP_DATABASE_PATH=testdata/GeoLite2-Country.mmdb ASYNC_TEST_TIMEOUT=30 pytest";
};
})
];
} // (flake-utils.lib.eachDefaultSystem (system:
inputs.uv2nix.url = "github:pyproject-nix/uv2nix";
inputs.uv2nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.uv2nix.inputs.pyproject-nix.follows = "pyproject-nix";
inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-build-systems.inputs.nixpkgs.follows = "nixpkgs";
inputs.pyproject-build-systems.inputs.pyproject-nix.follows = "pyproject-nix";
outputs = { self, nixpkgs, flake-utils, uv2nix, pyproject-nix, pyproject-build-systems }:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
perSystem = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
overlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
};
python = pkgs.python310;
pythonSet =
(pkgs.callPackage pyproject-nix.build.packages { inherit python; })
.overrideScope (pkgs.lib.composeManyExtensions [
pyproject-build-systems.overlays.default
overlay
]);
venv = pythonSet.mkVirtualEnv "netplay-index-env" workspace.deps.default;
in {
packages.netplay-index = venv;
packages.default = venv;
apps.default = {
type = "app";
program = "${venv}/bin/netplay-index";
};
in rec {
packages.netplay-index = pkgs.netplay-index;
defaultPackage = pkgs.netplay-index;
devShells.default = with pkgs; mkShell {
buildInputs = [ poetry uv ];
packages = [ uv ];
};
});
in
perSystem // {
overlays.default = final: prev: {
netplay-index = self.packages.${final.system}.netplay-index;
};
overlay = self.overlays.default;
};
}
));
}