Describe the issue
I'm trying to build the following flake, which apart from the overrides section is verbatim from a templates from poetry2nix's repo
{
description = "bear";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
{
packages = {
bear = mkPoetryApplication {
packageName = "bearctl";
projectDir = ./.;
overrides = poetry2nix.overrides.withDefaults (self: super: {
pycairo = super.pycairo.overridePythonAttrs (old: {
nativeBuildInputs =
[ self.meson pkgs.buildPackages.pkg-config ];
});
pygobject = super.pygobject.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
});
urllib3 = super.urllib3.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.hatch-vcs ];
});
pipewire-python = super.pipewire-python.overridePythonAttrs
(old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
});
});
buildInputs =
(with pkgs; [ pkgs.pipewire pkgs.lorri pkgs.xorg.xset pkgs.i3 ]);
};
default = self.packages.${system}.bear;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.myapp ];
packages = [ pkgs.poetry ];
};
});
}
which makes nix build balk with
✦ ❯ nix build .
warning: Git tree '/home/robin/devel/bearctl' is dirty
error:
… while evaluating the attribute 'packages.x86_64-linux.bear'
at /nix/store/2xz05z3ar2i1fr06mzr434f6n59513g6-source/flake.nix:88:11:
87| packages = {
88| bear = mkPoetryApplication {
| ^
89| packageName = "bearctl";
… while evaluating the attribute 'pkgs.buildPythonPackage'
at /nix/store/yy19v2dwb8ldphvia9smajvwv3ycx2c1-source/pkgs/development/interpreters/python/passthrufun.nix:87:5:
86| withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
87| pkgs = pythonPackages;
| ^
88| interpreter = "${self}/bin/${executable}";
(stack trace truncated; use '--show-trace' to show the full trace)
error: attribute 'overrides' missing
at /nix/store/2xz05z3ar2i1fr06mzr434f6n59513g6-source/flake.nix:92:25:
91|
92| overrides = poetry2nix.overrides.withDefaults (self: super: {
| ^
93|
I must be doing something very obvious incredibly wrong, but i can't seem to get this to work. What is happening?
thanks
With the new
poetry2nixAPI you need to buildpoetry2nix(and not onlymkPoetryApplication) frompkgsto access the overrides. This means that you should replacewith
Below are the modifications made to your flake.nix to make it work: