Poetry2nix flake 构建错误,因为 `poetry2nix.overrides` 属性似乎丢失了

问题描述 投票:0回答:1

描述问题

我正在尝试构建以下薄片,除了覆盖部分之外,它是逐字来自 poetry2nix 存储库中的模板

{
  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 ];
        };
      });
}

这让

nix build
犹豫不决

✦ ❯ 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|

我一定做了一些非常明显的错误,但我似乎无法让它发挥作用。发生什么事了?

谢谢

python python-poetry nix nix-flake
1个回答
0
投票

使用新的

poetry2nix
API,您需要从
poetry2nix
构建
mkPoetryApplication
(而不仅仅是
pkgs
)。这意味着您应该更换

inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;

poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs;};

以下是对 flake.nix 进行的修改以使其正常工作:

diff --git a/flake.nix b/flake.nix
index 9d159a6..0ba95c7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -10,15 +10,15 @@
     };
   };

-  outputs = { self, nixpkgs, flake-utils, poetry2nix }:
+  outputs = inputs @ { self, nixpkgs, flake-utils, ...}:
     flake-utils.lib.eachDefaultSystem (system:
       let
         pkgs = nixpkgs.legacyPackages.${system};
-        inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
+        poetry2nix = poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
       in
       {
         packages = {
-          bear = mkPoetryApplication {
+          bear = poetry2nix.mkPoetryApplication {
             packageName = "bearctl";
             projectDir = ./.
© www.soinside.com 2019 - 2024. All rights reserved.