Skip to content

Commit 3bef7dc

Browse files
committed
Switch over to uv2nix
1 parent 059b6aa commit 3bef7dc

9 files changed

Lines changed: 2041 additions & 3195 deletions

File tree

flake.lock

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

flake.nix

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@
77
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
88
poetry2nix.url = "github:nix-community/poetry2nix";
99
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
10+
11+
pyproject-nix = {
12+
url = "github:pyproject-nix/pyproject.nix";
13+
inputs.nixpkgs.follows = "nixpkgs";
14+
};
15+
16+
uv2nix = {
17+
url = "github:pyproject-nix/uv2nix";
18+
inputs.pyproject-nix.follows = "pyproject-nix";
19+
inputs.nixpkgs.follows = "nixpkgs";
20+
};
21+
22+
pyproject-build-systems = {
23+
url = "github:pyproject-nix/build-system-pkgs";
24+
inputs.pyproject-nix.follows = "pyproject-nix";
25+
inputs.uv2nix.follows = "uv2nix";
26+
inputs.nixpkgs.follows = "nixpkgs";
27+
};
1028
};
1129

1230
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, flake-parts-lib, ... }:
@@ -43,7 +61,28 @@
4361
];
4462
perSystem = { config, self', inputs', pkgs, lib, system, ... }:
4563
let
46-
python = pkgs.python3;
64+
workspace = inputs.uv2nix.lib.workspace.loadWorkspace {
65+
workspaceRoot = ./mkdocs;
66+
};
67+
overlay = workspace.mkPyprojectOverlay {
68+
sourcePreference = "wheel";
69+
};
70+
71+
pyprojectOverrides = import ./uv-overrides.nix;
72+
73+
python = pkgs.python312;
74+
75+
pythonSet =
76+
(pkgs.callPackage inputs.pyproject-nix.build.packages {
77+
inherit python;
78+
}).overrideScope
79+
(
80+
lib.composeManyExtensions [
81+
inputs.pyproject-build-systems.overlays.default
82+
overlay
83+
pyprojectOverrides
84+
]
85+
);
4786
in {
4887
_module.args.pkgs = import inputs.nixpkgs {
4988
inherit system;
@@ -55,11 +94,10 @@
5594

5695
devShells.default = pkgs.mkShell {
5796
nativeBuildInputs = [
58-
config.packages.default
59-
pkgs.poetry
6097
python.pkgs.plantuml-markdown
6198
pkgs.fontconfig
6299
pkgs.dejavu_fonts
100+
pkgs.uv
63101
];
64102
};
65103

@@ -68,13 +106,7 @@
68106
packages = {
69107
default = config.packages.mkdocs;
70108

71-
mkdocs-python = pkgs.poetry2nix.mkPoetryEnv {
72-
inherit python;
73-
projectDir = ./mkdocs;
74-
overrides = pkgs.poetry2nix.overrides.withDefaults
75-
(import ./python-overrides.nix);
76-
};
77-
109+
mkdocs-python = pythonSet.mkVirtualEnv "mkdocs-env" workspace.deps.default;
78110
mkdocs = pkgs.runCommand "mkdocs" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
79111
makeWrapper ${config.packages.mkdocs-python}/bin/mkdocs $out/bin/mkdocs \
80112
--set PATH ${lib.makeBinPath [

mkdocs/README.md

Whitespace-only changes.

mkdocs/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello from mkdocs!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

0 commit comments

Comments
 (0)