!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

306 Members
https://github.com/nix-community/poetry2nix57 Servers

Load older messages


SenderMessageTime
4 Nov 2024
@9456ed88e6:matrix.org9456ed88e6
In reply to @picog:matrix.org

Seems to work fine for me fwiw

tree
.
├── flake.lock
├── flake.nix
└── test
    ├── pack
    │   ├── do_stuff.py
    │   └── __init__.py
    ├── poetry.lock
    └── pyproject.toml
cat flake.nix
{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  outputs = { self, nixpkgs, poetry2nix }:
  let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
    inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
    app = mkPoetryApplication { projectDir = ./test; };
  in
  {
    devShells.x86_64-linux.default = pkgs.mkShell {
      packages = with pkgs; [ app ];
    };

  };
}
cat test/pyproject.toml
\[tool.poetry\]
name = "pack"
version = "0.1.0"
description = ""
authors = \["Your Name [you@example.com](mailto:you@example.com)"\]

\[tool.poetry.dependencies\]
python = "^3.11"

\[tool.poetry.scripts\]
foo = "pack.do\_stuff:main"

\[build-system\]
requires = \["poetry-core"\]
build-backend = "poetry.core.masonry.api"
foo
Doing stuff
Thanks for trying it, I intend on starting a new project from scratch to see what I can make work.
16:37:30
@aevoo:matrix.orgAevoo changed their display name from aevoo to Aevoo.16:52:08
@truh:matrix.orgtruh Curious my ModuleNotFoundError started with this poetry2nix change https://github.com/nix-community/poetry2nix/pull/1785. And it's caused by me passing groups=[] to p2n.mkPoetryApplication. Passing groups=["main"] (the new default) solves the problem. 18:10:15
5 Nov 2024
@spacekookie:fairydust.spacekookie joined the room.14:52:26
@spacekookie:fairydust.spacekookie

Hey! I'm trying to nixify a poetry project and having issues with one of the tool hashes (for ruff, which I think is a linter?).

The build fails with

         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=

and I'm trying to override the package like this (as an arg to mkPoetryApplication:

    overrides = poetry2nix.overrides.withDefaults (self: super: {
      ruff = super.ruff.overrideAttrs ({ src, ... }: {
        src = {
          inherit (src) owner repo rev;
          hash = "sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=";
        };
      });
    });

but I'm still getting the hash mismatch. Any ideas what I'm doing wrong?

14:59:56
@spacekookie:fairydust.spacekookie *

Hey! I'm trying to nixify a poetry project and having issues with one of the tool hashes (for ruff, which I think is a linter?).

The build fails with

specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got:    sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=

and I'm trying to override the package like this (as an arg to mkPoetryApplication:

overrides = poetry2nix.overrides.withDefaults (self: super: { ruff = super.ruff.overrideAttrs ({ src, ... }: {
        src = {
          inherit (src) owner repo rev;
          hash = "sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=";
        };
      });
    });

but I'm still getting the hash mismatch. Any ideas what I'm doing wrong?

15:00:12
@spacekookie:fairydust.spacekookie *

Hey! I'm trying to nixify a poetry project and having issues with one of the tool hashes (for ruff, which I think is a linter?).

The build fails with

specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got:    sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=

and I'm trying to override the package like this (as an arg to mkPoetryApplication:

overrides = poetry2nix.overrides.withDefaults (self: super: { 
  ruff = super.ruff.overrideAttrs ({ src, ... }: {
    src = {
    inherit (src) owner repo rev;
    hash = "sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=";
    };
  });
});

but I'm still getting the hash mismatch. Any ideas what I'm doing wrong?

15:00:35
@spacekookie:fairydust.spacekookie *

Hey! I'm trying to nixify a poetry project and having issues with one of the tool hashes (for ruff, which I think is a linter?).

The build fails with

specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got:       sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=

and I'm trying to override the package like this (as an arg to mkPoetryApplication:

overrides = poetry2nix.overrides.withDefaults (self: super: { 
  ruff = super.ruff.overrideAttrs ({ src, ... }: {
    src = {
    inherit (src) owner repo rev;
    hash = "sha256-TPr6YdSb5JKltXHDi1PdGzPYjmmsbCFQKxIiJURrBMI=";
    };
  });
});

but I'm still getting the hash mismatch. Any ideas what I'm doing wrong?

15:00:57
@spacekookie:fairydust.spacekookieThe derivation hash isn't changing so I assume the override isn't being applied15:01:22
@k900:0upti.meK900It's probably cargoHash15:01:40
@k900:0upti.meK900The way we handle overrides for those sucks15:01:45
@spacekookie:fairydust.spacekookieOoh15:01:59
@k900:0upti.meK900https://github.com/nix-community/poetry2nix/blob/master/overrides/default.nix#L341815:02:14
@spacekookie:fairydust.spacekookieI forgot how to set those in the first place lol15:02:14
@spacekookie:fairydust.spacekookieThanks! :)15:02:27
@spacekookie:fairydust.spacekookieAh okay. Yeah this project uses 0.7.1 so I guess I should do a PR to poetry2nix to update these?15:03:10
@spacekookie:fairydust.spacekookieI am getting that "unknown ruff version" warning :P Good to know where it comes from15:03:29
@k900:0upti.meK900Probably yes15:04:01
6 Nov 2024
@spacekookie:fairydust.spacekookie

I fixed the ruff problem (wip PR with not all the in-between versions added), now failing on the next hurdle: pydantic-xml fails to build because: No module named 'poetry'.

I read the edgecases.md and tried adding poetry to the build inputs of the package, but to no avail. Anything obviously wrong with this?

          pydantic-xml = super.pythonPackages.pydantic-xml.overridePythonAttrs
            (old: {
              buildInputs = (old.buildInputs or [ ]) ++ (pkgs.lib.traceVal [ super.poetry ]);
            });

(the trace is being printed as trace: [ «thunk» «thunk» ]

08:04:49
@spacekookie:fairydust.spacekookie *

I fixed the ruff problem (wip PR with not all the in-between versions added), now failing on the next hurdle: pydantic-xml fails to build because: No module named 'poetry'.

I read the edgecases.md and tried adding poetry to the build inputs of the package, but to no avail. Anything obviously wrong with this?

          pydantic-xml = super.pythonPackages.pydantic-xml.overridePythonAttrs
            (old: {
              buildInputs = (old.buildInputs or [ ]) ++ (pkgs.lib.traceVal [ super.poetry ]);
            });

(the trace is being printed as trace: [ «thunk» «thunk» ]

08:05:30
@k900:0upti.meK900 You probably want super.poetry-core 08:07:35
@k900:0upti.meK900Also, check build-systems.json08:07:41
@k900:0upti.meK900That's an easier way to do basically this08:07:45
@spacekookie:fairydust.spacekookieoh okay!08:10:44
@spacekookie:fairydust.spacekookieActually yeah I saw that earlier and forgot about it08:10:54
@spacekookie:fairydust.spacekookie Is there a way to include arbitrary extra files in the output path of the root mkPoetryApplication build? I tried adding the name of that package (builder-tools for me) to the overrides section but that doesn't seem to be evaluated 09:26:17
@spacekookie:fairydust.spacekookie * Is there a non-obvious/ not-document dway to include arbitrary extra files in the output path of the root mkPoetryApplication build? I tried adding the name of that package (builder-tools for me) to the overrides section but that doesn't seem to be evaluated 09:26:42
@spacekookie:fairydust.spacekookie * Is there a non-obvious/ not-document way to include arbitrary extra files in the output path of the root mkPoetryApplication build? I tried adding the name of that package (builder-tools for me) to the overrides section but that doesn't seem to be evaluated 09:28:11
@truh:matrix.orgtruhI think you can use the usual nix derivation hooks. postInstall maybe09:28:13
@spacekookie:fairydust.spacekookieI'll try that09:28:44

Show newer messages


Back to Room ListRoom Version: 6