Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@
kevmOverlay = final: prev:
let
python = final."python${pythonVer}";
kevm-pyk-pyproject = final.callPackage ./nix/kevm-pyk-pyproject {
inherit uv2nix;
};
kevm-pyk = final.callPackage ./nix/kevm-pyk {
inherit pyproject-nix pyproject-build-systems uv2nix python;
inherit pyproject-nix pyproject-build-systems kevm-pyk-pyproject python;
pyproject-overlays = [
(k-framework.overlays.pyk-pyproject system)
];
};
kevm = final.callPackage ./nix/kevm {
inherit kevm-pyk python;
Expand All @@ -80,7 +86,7 @@
kevm-test = final.callPackage ./nix/kevm/test.nix { };
kevm-profile = final.callPackage ./package/nix/profile.nix { };
in {
inherit kevm kevm-test kevm-profile;
inherit kevm kevm-test kevm-profile kevm-pyk-pyproject;
};
pkgs = import nixpkgs {
inherit system;
Expand Down Expand Up @@ -146,7 +152,7 @@
};

packages = rec {
inherit (pkgs) kevm-pyk kevm kevm-test;
inherit (pkgs) kevm-pyk kevm kevm-test kevm-pyk-pyproject;
default = kevm;
profile = pkgs.kevm-profile;

Expand All @@ -160,8 +166,15 @@
};
};
}) // {
overlays.default = final: prev: {
inherit (self.packages.${final.system}) kevm;
overlays = {
default = final: prev: {
inherit (self.packages.${final.system}) kevm;
};
# this pyproject-nix overlay allows for overriding the python packages that are otherwise locked in `uv.lock`
# by using this overlay in dependant nix flakes, you ensure that nix overrides also override the python package
pyk-pyproject = system: final: prev: {
inherit (self.packages.${system}.kevm-pyk-pyproject.lockFileOverlay final prev) kevm-pyk;
};
};
};
}
23 changes: 23 additions & 0 deletions nix/kevm-pyk-pyproject/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
lib,
callPackage,

uv2nix,
}:
let
src = callPackage ../kevm-source { };

# load a uv workspace from a workspace root
workspace = uv2nix.lib.workspace.loadWorkspace {
workspaceRoot = "${src}/kevm-pyk";
};

# create overlay
lockFileOverlay = workspace.mkPyprojectOverlay {
# prefer "wheel" over "sdist" due to maintance overhead
# there is no bundled set of overlays for "sdist" in uv2nix, in contrast to poetry2nix
sourcePreference = "wheel";
};
in {
inherit lockFileOverlay workspace;
}
26 changes: 6 additions & 20 deletions nix/kevm-pyk/default.nix
Original file line number Diff line number Diff line change
@@ -1,47 +1,33 @@
{
lib,
callPackage,
stdenvNoCC,

blockchain-k-plugin-src,

pyproject-nix,
pyproject-build-systems,
uv2nix,
kevm-pyk-pyproject,
pyproject-overlays ? [ ],

python
}:
let
inherit (kevm-pyk-pyproject) lockFileOverlay workspace;

pyproject-util = callPackage pyproject-nix.build.util {};
pyproject-packages = callPackage pyproject-nix.build.packages {
inherit python;
};

src = callPackage ../kevm-source { };

# load a uv workspace from a workspace root
workspace = uv2nix.lib.workspace.loadWorkspace {
workspaceRoot = "${src}/kevm-pyk";
};

# create overlay
lockFileOverlay = workspace.mkPyprojectOverlay {
# prefer "wheel" over "sdist" due to maintance overhead
# there is no bundled set of overlays for "sdist" in uv2nix, in contrast to poetry2nix
sourcePreference = "wheel";
};

buildSystemsOverlay = import ./build-systems-overlay.nix;

# construct package set
pythonSet = pyproject-packages.overrideScope (lib.composeManyExtensions [
pythonSet = pyproject-packages.overrideScope (lib.composeManyExtensions ([
# make build tools available by default as these are not necessarily specified in python lock files
pyproject-build-systems.overlays.default
# include all packages from the python lock file
lockFileOverlay
# add build system overrides to certain python packages
buildSystemsOverlay
]);
] ++ pyproject-overlays));
in pyproject-util.mkApplication {
# default dependancy group enables no optional dependencies and no dependency-groups
venv = pythonSet.mkVirtualEnv "kevm-pyk-env" workspace.deps.default;
Expand Down