flake: Convert to uv2nix

This commit is contained in:
OatmealDome
2025-08-21 22:22:36 +00:00
parent 6728b209ec
commit 726aff838f

View File

@@ -3,31 +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: {
analytics-ingest = prev.poetry2nix.mkPoetryApplication {
projectDir = ./.;
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
perSystem = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
overlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
};
})
];
} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in rec {
packages.analytics-ingest = pkgs.analytics-ingest;
defaultPackage = pkgs.analytics-ingest;
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 "analytics-ingest-env" workspace.deps.default;
in {
packages.analytics-ingest = venv;
packages.default = venv;
devShells.default = with pkgs; mkShell {
buildInputs = [ poetry uv ];
apps.default = {
type = "app";
program = "${venv}/bin/analytics-ingest";
};
devShells.default = pkgs.mkShell {
packages = [ pkgs.uv ];
};
});
in
perSystem // {
overlays.default = final: prev: {
analytics-ingest = self.packages.${final.system}.analytics-ingest;
};
}
));
overlay = self.overlays.default;
};
}