Skip to content

Commit e5dd163

Browse files
committed
Move to uv2nix
1 parent 28176ba commit e5dd163

File tree

4 files changed

+436
-122
lines changed

4 files changed

+436
-122
lines changed

flake.lock

Lines changed: 61 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 90 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,132 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
6+
67
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
7-
poetry2nix = {
8-
url = "github:nix-community/poetry2nix";
9-
inputs = {
10-
nixpkgs.follows = "nixpkgs";
11-
flake-utils.follows = "utils/flake-utils";
12-
};
13-
};
8+
149
nemo = {
1510
url = "github:knowsys/nemo/refs/tags/v0.7.0";
1611
inputs = {
1712
nixpkgs.follows = "nixpkgs";
1813
utils.follows = "utils";
1914
};
2015
};
16+
17+
pyproject-nix = {
18+
url = "github:pyproject-nix/pyproject.nix";
19+
inputs.nixpkgs.follows = "nixpkgs";
20+
};
21+
22+
uv2nix = {
23+
url = "github:pyproject-nix/uv2nix";
24+
inputs.pyproject-nix.follows = "pyproject-nix";
25+
inputs.nixpkgs.follows = "nixpkgs";
26+
};
27+
28+
pyproject-build-systems = {
29+
url = "github:pyproject-nix/build-system-pkgs";
30+
inputs.pyproject-nix.follows = "pyproject-nix";
31+
inputs.uv2nix.follows = "uv2nix";
32+
inputs.nixpkgs.follows = "nixpkgs";
33+
};
2134
};
2235

2336
outputs =
2437
{
2538
self,
2639
utils,
27-
poetry2nix,
2840
nemo,
41+
uv2nix,
42+
pyproject-nix,
43+
pyproject-build-systems,
2944
...
3045
}@inputs:
3146
let
3247
inherit (utils.lib) mkFlake;
48+
inherit (inputs.nixpkgs) lib;
49+
50+
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
51+
hacks = pkgs: pkgs.callPackage pyproject-nix.build.hacks { };
52+
overlay = workspace.mkPyprojectOverlay {
53+
sourcePreference = "wheel";
54+
};
55+
56+
nemoOverlay = pkgs: final: prev: {
57+
nemo-python = (hacks final).nixpkgsPrebuilt {
58+
from = nemo.packages."${pkgs.system}".nemo-python;
59+
prev = prev.requests; # ugly hack, but we require requests anyway
60+
};
61+
};
62+
63+
pyprojectOverrides = final: prev: {
64+
networkit = prev.networkit.overrideAttrs (old: {
65+
nativeBuildInputs = old.nativeBuildInputs ++ [
66+
(final.resolveBuildSystem {
67+
cmake = [ ];
68+
cython = [ ];
69+
scikit-build-core = [ ];
70+
setuptools = [ ];
71+
numpy = [ ];
72+
})
73+
];
74+
});
75+
};
76+
77+
python = pkgs: pkgs.python312;
78+
79+
pythonSet =
80+
pkgs:
81+
(pkgs.callPackage pyproject-nix.build.packages {
82+
python = python pkgs;
83+
}).overrideScope
84+
(
85+
lib.composeManyExtensions [
86+
pyproject-build-systems.overlays.default
87+
overlay
88+
(nemoOverlay pkgs)
89+
pyprojectOverrides
90+
]
91+
);
92+
93+
virtualenv =
94+
pkgs:
95+
(pythonSet pkgs).mkVirtualEnv "knowledge-graphs-venv" (
96+
workspace.deps.all // { nemo-python = [ ]; }
97+
);
3398
in
3499
mkFlake {
35100
inherit self inputs;
36101

37102
channels.nixpkgs.overlaysBuilder = channels: [
38-
poetry2nix.overlays.default
39103
nemo.overlays.default
40104
];
41105

42106
outputsBuilder = channels: {
43107
devShells.default =
44108
let
45109
pkgs = channels.nixpkgs;
46-
poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
47-
projectDir = ./.;
48-
overrides = pkgs.poetry2nix.overrides.withDefaults (
49-
self: super: {
50-
networkit = super.networkit.overridePythonAttrs (old: {
51-
src = pkgs.fetchFromGitHub {
52-
owner = "networkit";
53-
repo = "networkit";
54-
rev = "9b33495752e5b98f1401faea911c026279a0d478";
55-
hash = "sha256-sarzPsbrXpMam16z2kKn53nAW2I99CQ67diaIYLKjCI=";
56-
fetchSubmodules = true;
57-
58-
};
59-
nativeBuildInputs = [
60-
self.cython
61-
pkgs.cmake
62-
] ++ (old.nativeBuildInputs or [ ]);
63-
64-
buildInputs = [ self.scikit-build ] ++ (old.buildInputs or [ ]);
65-
dontUseCmakeConfigure = true;
66-
});
67-
}
68-
);
69-
extraPackages = pypkgs: [ pkgs.nemo-python ];
70-
};
71110
in
72-
poetryEnv.env.overrideAttrs (oldAttrs: {
73-
buildInputs = [
111+
pkgs.mkShell {
112+
packages = [
113+
(virtualenv pkgs)
74114
pkgs.black
75-
pkgs.poetry
76115
pkgs.mypy
77116
pkgs.nemo
117+
pkgs.uv
78118
];
79-
});
119+
env =
120+
{
121+
UV_NO_SYNC = "1";
122+
UV_PYTHON_DOWNLOADS = "never";
123+
UV_PYTHON = python pkgs;
124+
}
125+
// lib.optionalAttrs pkgs.stdenv.isLinux {
126+
LD_LIBRARY_PATH = lib.makeLibraryPath pkgs.pythonManylinuxPackages.manylinux1;
127+
};
128+
shellHook = ''
129+
unset PYTHONPATH
130+
'';
131+
};
80132
};
81133
};
82134
}

0 commit comments

Comments
 (0)