Skip to content

Commit

Permalink
Add poetry2nix to flake inputs and use it
Browse files Browse the repository at this point in the history
Fixes #441
  • Loading branch information
avdv committed Nov 8, 2023
1 parent 89ccb0c commit 13effd5
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 4 deletions.
116 changes: 115 additions & 1 deletion flake.lock

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

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
Expand Down
1 change: 1 addition & 0 deletions testing/python/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use_repo(non_module_deps, "nixpkgs")
use_repo(non_module_deps, "nixpkgs_python_toolchain")
use_repo(non_module_deps, "nixpkgs_python_configure_test")
use_repo(non_module_deps, "nixpkgs_python_toolchain_python3")
use_repo(non_module_deps, "poetry2nix")
register_toolchains("@nixpkgs_python_toolchain//:all")

use_repo(non_module_deps, "generated_poetry_packages_deps")
Expand Down
5 changes: 3 additions & 2 deletions testing/python/poetry.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let
nixpkgs = import <nixpkgs> {};
inherit (nixpkgs) lib poetry2nix python3 runCommand;
nixpkgs = import <nixpkgs> { };
poetry2nix = import <poetry2nix> { pkgs = nixpkgs; };
inherit (nixpkgs) python3;

args = {
python = python3;
Expand Down
12 changes: 12 additions & 0 deletions testing/python/poetry2nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
poetry2nix =
let
src = lock.nodes.poetry2nix.locked;
in
assert src.type == "github";
fetchTarball {
url = "https://github.com/${src.owner}/${src.repo}/archive/${src.rev}.tar.gz";
sha256 = src.narHash;
};
in import poetry2nix
11 changes: 10 additions & 1 deletion testing/python/tests/nixpkgs_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def nixpkgs_repositories(*, bzlmod):
nix_file_deps = ["//:flake.lock"],
)

nixpkgs_local_repository(
name = "poetry2nix",
nix_file = "//:poetry2nix.nix",
nix_file_deps = ["//:flake.lock"],
)

# Tests implicitly depend on Java
nixpkgs_java_configure(
name = "nixpkgs_java_runtime",
Expand Down Expand Up @@ -43,7 +49,10 @@ def nixpkgs_repositories(*, bzlmod):

nixpkgs_python_repository(
name = "poetry_packages",
repository = "@nixpkgs",
repositories = {
"nixpkgs": "@nixpkgs",
"poetry2nix": "@poetry2nix",
},
nix_file = "//:poetry.nix",
nix_file_deps = [
"//:pyproject.toml",
Expand Down

0 comments on commit 13effd5

Please sign in to comment.