From 55d0da1263edeb0af3553c178ca9d9b044e73694 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 28 Sep 2023 04:56:44 -0400 Subject: fix(flake): use custom buildPhase instead of pypBuildHook --- nix/derivation.nix | 16 +++++++++++++--- nix/dev.nix | 10 +++++++--- nix/packages.nix | 31 +++++++++++-------------------- 3 files changed, 31 insertions(+), 26 deletions(-) (limited to 'nix') diff --git a/nix/derivation.nix b/nix/derivation.nix index 4e32095..483aeef 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -6,16 +6,26 @@ pydantic, uvicorn, self, - version, + build, + wheel, }: buildPythonPackage { pname = "guzzle-api"; - inherit version; + version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; src = lib.cleanSource self; format = "flit"; doCheck = false; + dontUsePypaBuild = true; + + # TODO: find out what's going on with pypaBuildHook + buildPhase = '' + runHook preBuild + pyproject-build --no-isolation --outdir dist/ --wheel $pypaBuildFlags + runHook postBuild + ''; + propagatedBuildInputs = [fastapi pydantic uvicorn]; - propagatedNativeBuildInputs = [flit-core]; + nativeBuildInputs = [flit-core build wheel]; } diff --git a/nix/dev.nix b/nix/dev.nix index b394c6c..9ebb07f 100644 --- a/nix/dev.nix +++ b/nix/dev.nix @@ -5,8 +5,9 @@ ... }: { perSystem = { - config, pkgs, + config, + self', ... }: { pre-commit = { @@ -24,8 +25,11 @@ devShells.default = pkgs.mkShell { shellHook = config.pre-commit.installationScript; - packages = [ - (pkgs.python311.withPackages (p: with p; [isort yapf pylint])) + inputsFrom = [self'.packages.guzzle-api]; + packages = with pkgs.python311Packages; [ + isort + yapf + pylint ]; }; }; diff --git a/nix/packages.nix b/nix/packages.nix index 8722ad1..bc679c7 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -1,29 +1,20 @@ -{self, ...}: let - version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; - commonArgs = {inherit self version;}; -in { +{self, ...}: { perSystem = { + lib, pkgs, - self', ... - }: { + }: let + pkgs' = lib.fix (final: self.overlays.default final pkgs); + in { packages = { - guzzle-api = pkgs.python311Packages.callPackage ./derivation.nix commonArgs; - guzzle-api-server = pkgs.python311Packages.callPackage ./server.nix {inherit (self'.packages) guzzle-api;}; - default = self'.packages.guzzle-api; + inherit (pkgs') guzzle-api guzzle-api-server; + default = pkgs'.guzzle-api-server; }; }; - flake.overlays.default = final: prev: { - python = prev.python.override { - packageOverrides = _: prev': { - guzzle-api = prev'.callPackage ./derivation.nix commonArgs; - }; + flake.overlays.default = final: prev: + with prev.python311Packages; { + guzzle-api = callPackage ./derivation.nix {inherit self;}; + guzzle-api-server = callPackage ./server.nix {inherit (final) guzzle-api;}; }; - - pythonPackages = final.python.pkgs; - - guzzle-api = final.pythonPackages.callPackage ./derivation.nix commonArgs; - guzzle-api-server = final.pythonPackages.callPackage ./server.nix {}; - }; } -- cgit v1.2.3