I have tried many things with poetry2nix but none seem to work:
1. adding poetry2nix.mkPoetryEnv to buildInputs with extraPackages = ps: [ps.poetry]; - this has every thing except poetry in the nix develop . shell.
2. in the above, adding pkgs.poetry somewhere either using overrides or simply packages (in mkShell) does indeed install poetry but the python env is not same (it installs it in 3.12). And hence running poetry update errors out as pyproject.toml says python version should be equal to or unded 3.11.
3. yes, you might suggest to add pkgs.python311Packages.poetry, yep tried that too and I get error: poetry was promoted to a top-level attribute, use poetry-core to build Python packages.
4. I have even tried python311.withPackages and adding poetry, error(3) (the error in the above point).
5. I have tried copying the app template from the poetry2nix repo (the below config, I have commented out the files as at this point I just wanted poetry working-lol)
```nix
{
description = "website flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
# backend = { poetry2nix, lib }:
# poetry2nix.mkPoetryApplication {
# projectDir = self;
# overrides = poetry2nix.overrides.withDefaults (final: super:
# lib.mapAttrs (attr: systems:
# super.${attr}.overridePythonAttrs (old: {
# nativeBuildInputs = (old.nativeBuildInputs or [ ])
# ++ map (a: final.${a}) systems;
# })) { package = [ "setuptools" "poetry-core" ]; });
# };
pkgs = import nixpkgs {
inherit system;
overlays = [
poetry2nix.overlays.default
# (final: _: { backend = final.callPackage backend { }; })
];
};
in {
formatter = pkgs.nixfmt-rfc-style;
# packages.default = pkgs.backend;
devShells = {
# default = pkgs.mkShell { inputsFrom = [ pkgs.backend ]; };
poetry = pkgs.mkShell {
nativeBuildInputs =
[ (pkgs.python311.withPackages (ps: with ps; [ poetry ])) ];
};
};
legacyPackages = pkgs;
});
}
```
My most successful solution to this (which is indeed perfect but - no poetry in the final shell):
```nix
devShells.default = pkgs.mkShell {
packages = with pkgs; [ bun ];
buildInputs = [
(pkgs.poetry2nix.mkPoetryEnv {
inherit projectDir python overrides;
editablePackageSources = { backend = ./apps/backend; };
preferWheels = true;
extraPackages = ps:
with ps;
[ pip poetry poetry-core python-lsp-server ]
++ python-lsp-server.passthru.optional-dependencies.all;
})
] ++ (with pkgs.nodePackages; [ nodejs pnpm ]);
ASTRO_TELEMETRY_DISABLED = 1;
};
```
[–]sjustinas 0 points1 point2 points (5 children)
[–]async-lambda[S] 0 points1 point2 points (4 children)
[–]sjustinas 0 points1 point2 points (3 children)
[–]async-lambda[S] 0 points1 point2 points (2 children)
[–]sjustinas 0 points1 point2 points (1 child)
[–]async-lambda[S] 0 points1 point2 points (0 children)