nix-community/poetry2nix

error: poetry2nix is now maintained out-of-tree.

Opened this issue · 1 comments

I see this error has reference here and here but I cant seem to figure out what I'm doing differently.

I'm trying to add a python poetry package to my Nixos configuration. It's not available in the nixpkgs collection. I want to be able to install this package on my system with pkgs.example_package. Here is an example of a package I tried to install from this tutorial:

# hello_poetry2nix (default.nix)
{ pkgs ? import <nixpkgs> { }
, ...
}:

let
  name = "hello_poetry2nix";
  rev = "4431812218e1963fd34f4d9d22dcd688a4c33fb4";
  hash = "sha256-iHqzA/HJ+vb7O5vpGpA1eR3BcoGDPE2QOqQQpOp0zFQ=";

  src = pkgs.fetchFromGitHub {
    inherit rev hash;

    owner = "wilsonehusin";
    repo = "hello-poetry2nix";
  };
in
pkgs.poetry2nix.mkPoetryApplication {
  inherit name src;

  pname = name;
  version = rev;
  projectDir = src;
}

I've added poetry2nix as an input to my flake.nix:

# flake.nix
  inputs = {
    # Nixpkgs
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";

    poetry2nix.url = "github:nix-community/poetry2nix";
  outputs =
    { self
    , nixpkgs
    , home-manager
    , poetry2nix
    , ...
    } @ inputs:
    let
      inherit (self) outputs;
      systems = [
        "x86_64-linux"
      ];
      forAllSystems = nixpkgs.lib.genAttrs systems;
      specialArgs = { inherit inputs outputs; };
    in
    {
      packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
      overlays = import ./overlays { inherit inputs; };
      nixosModules = import ./modules/nixos;
      homeManagerModules = import ./modules/home-manager;

      # System level configs
      nixosConfigurations = {
        desktop = nixpkgs.lib.nixosSystem {
          inherit specialArgs;
          modules = [
            ./hosts/nixdev
            home-manager.nixosModules.home-manager
            {
              home-manager.extraSpecialArgs = specialArgs;
            }
          ];
        };
      };
    };
}

I call the package:

pkgs: {
  hello_poetry2nix = pkgs.callPackage ./hello_poetry2nix { };
}

Then in my configuration I want to install the package:

  home.packages = [
    pkgs.hello_poetry2nix
  ];

but I get:
error: poetry2nix is now maintained out-of-tree. Please use https://github.com/nix-community/poetry2nix/

I've read through the documentation and other people's configurations, but I cant seem to find any working examples similar to what I want to achieve.

Any assistance would be greatly appreciated.

You need to put an overlay on your nixpkgs, otherwise pkgs.poetry2nix is still the originial nixpkgs 'just-the-error-message' one.

The docs have this snippet:

pkgs = nixpkgs.legacyPackages.${system}.extend poetry2nix.overlays.default;
myPythonApp = pkgs.poetry2nix.mkPoetryApplication { projectDir = self; };

but I think you can get away wit putting poetry2nix.overlays.default; in your overlays.