Skip to content

Commit

Permalink
Merge pull request #11 from Multipixelone/uv
Browse files Browse the repository at this point in the history
migrate flake to uv2nix
  • Loading branch information
chmouel authored Nov 21, 2024
2 parents 077c28a + 45ce22f commit 7e07f62
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 94 deletions.
115 changes: 52 additions & 63 deletions packaging/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 43 additions & 31 deletions packaging/flake.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
{
description = "Python program to show your google calendar next meeting";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
pyproject-nix = {
url = "github:nix-community/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.uv2nix.follows = "uv2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
uv2nix = {
url = "github:adisbladis/uv2nix";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
flake-utils,
poetry2nix,
uv2nix,
pyproject-nix,
pyproject-build-systems,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
p2n = import poetry2nix {inherit pkgs;};
python = pkgs.python3;
projectDir = ../.;
overrides = p2n.overrides.withDefaults (final: prev: {
# use wheels to build ruff & mypy
ruff = prev.ruff.override {
preferWheel = true;
};
mypy = prev.mypy.override {
preferWheel = true;
};
});
poetry_env = p2n.mkPoetryEnv {
inherit python projectDir overrides;
};
poetry_app = p2n.mkPoetryApplication {
inherit python projectDir overrides;
};
inherit (nixpkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python312;
# setup uv2nix workspace & overlay
workspace = uv2nix.lib.workspace.loadWorkspace {workspaceRoot = ../.;};
overlay = workspace.mkPyprojectOverlay {
# Prefer prebuilt binary wheels as a package source.
sourcePreference = "wheel";
};
pythonSet =
# Use base package set from pyproject.nix builders
(pkgs.callPackage pyproject-nix.build.packages {
inherit python;
})
.overrideScope
(
lib.composeManyExtensions [
pyproject-build-systems.overlays.default
overlay
]
);
in {
packages = {
nextmeeting = poetry_app;
default = self.packages.${system}.nextmeeting;
${system}.default = pythonSet.mkVirtualEnv "nextmeeting" workspace.deps.default;
};
devShells.default =
pkgs.mkShell {packages = [pkgs.poetry poetry_env];};
});
}

0 comments on commit 7e07f62

Please sign in to comment.