!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

319 Members
https://github.com/nix-community/poetry2nix63 Servers

Load older messages


SenderMessageTime
3 Sep 2024
@rpop0:matrix.orgrpop0I tried using different versions of poetry2nix, including latest commit, some random tags from 2024 and 2023 but I still get this issue.22:32:51
@adis:blad.isadisbladis
In reply to @rpop0:matrix.org

Hey so I just got into nix flakes and I'm trying to make the following flake:

{
  description = "A very basic flake";

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

  outputs = { nixpkgs, ... } @ inputs:
  let
    pkgs = nixpkgs.legacyPackages.aarch64-darwin;
    poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
    pythonEnv = poetry2nix.mkPoetryEnv {
        python = pkgs.python311;
        projectDir = ./.;
    };
  in 
  {
      devShells.aarch64-darwin.default = pkgs.mkShell {
          packages = [ pkgs.python311 pkgs.poetry pythonEnv ];
      };
  };
}

But I am getting this error:

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/bd4fmzws6n5542khxbifbkr6nrygi232-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/bd4fmzws6n5542khxbifbkr6nrygi232-source/pkgs/stdenv/generic/make-derivation.nix:380:7:
          379|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          380|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          381|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: opening file '/nix/store/afbjx0hhv5q3lkv0rmcmagd3wkq1vhrr-source/poetry.lock': No such file or directory
It's probably a flake thing: Add poetry.lock to git.
22:37:38
@rpop0:matrix.orgrpop0
In reply to @adis:blad.is
It's probably a flake thing: Add poetry.lock to git.
So poetry.lock is already added to git, only unstaged files are flake.nix and flake.lock. Do these two files also need to be in git?
22:41:30
@adis:blad.isadisbladisYes. If a flake is in a git repo nothing that isn't staged is considered22:42:02
@rpop0:matrix.orgrpop0Yeah I just noticed that if the flake is added in the .gitignore, it also doesn't work. Well that throws a wrench in my plans22:43:47
@rpop0:matrix.orgrpop0I was planning to use this strictly for my dev environment setup22:44:07
@adis:blad.isadisbladisYou could also not use flakes?22:45:27
@rpop0:matrix.orgrpop0What would be the alternative? nix-shell?22:46:11
@adis:blad.isadisbladis
In reply to @rpop0:matrix.org
What would be the alternative? nix-shell?
Yes, nix-shell
22:47:03
@adis:blad.isadisbladis https://github.com/edolstra/flake-compat might be an option if you still want to express yourself as a flake, but eval using nix-shell. It still does the whole fetchGit thing iirc, so you'll have to provide it with a source that doesn't look like a git repo 22:47:57
@rpop0:matrix.orgrpop0So just to understand, for example in a project when using a flake that would be for setting up a more general environment to be used by everyone. On the other hand, if I need something set up just for myself (Or I'm the only one interested in using nix), a nix-shell would be the better solution?22:52:07
@adis:blad.isadisbladis
In reply to @rpop0:matrix.org
So just to understand, for example in a project when using a flake that would be for setting up a more general environment to be used by everyone. On the other hand, if I need something set up just for myself (Or I'm the only one interested in using nix), a nix-shell would be the better solution?
Flakes and nix-shell are morally equivalent (see https://jade.fyi/blog/flakes-arent-real/ )
22:59:51
@rpop0:matrix.orgrpop0Like in my specific case, only me and 2 other team members are doing our development in a linux environment, while the rest of our team are on windows. Out of the 3 of us on linux, I'm the only one interested in nix and configuring my environment that way, so I'd rather not bother other people with my configurations and things23:00:09
@adis:blad.isadisbladisThe reason why I'm suggesting nix-shell here is because it doesn't have strange special behaviour re git 23:00:27
@rpop0:matrix.orgrpop0Alright, I'll look into that23:01:17
@rpop0:matrix.orgrpop0Thanks23:01:55
@djacu:matrix.org@djacu:matrix.org left the room.23:29:35
4 Sep 2024
@vengmark2:matrix.orgl0b0
In reply to @vengmark2:matrix.org

Yep, it's definitely something to do with the wrong Python version - I see mention of Python 3.12 in pre-commit output, and both mypy and pylint complain about missing libraries which are installed in the poetry2nix package set. Also:

❯ type -a python
python is /nix/store/d6cy7nfpwjppghqg3mav9537ypl6ww82-python3-3.11.9-env/bin/python
python is /nix/store/pgb120fb7srbh418v4i2a70aq1w9dawd-python3-3.12.5/bin/python

Any idea why this could be? I don't have Python installed at the OS level:

❯ python --version
The program 'python' is currently not installed. It is provided by
several packages. You can install it by typing one of the following:

It's even easier to see the issue in this PR.

22:44:08
@vengmark2:matrix.orgl0b0
In reply to @vengmark2:matrix.org

Yep, it's definitely something to do with the wrong Python version - I see mention of Python 3.12 in pre-commit output, and both mypy and pylint complain about missing libraries which are installed in the poetry2nix package set. Also:

❯ type -a python
python is /nix/store/d6cy7nfpwjppghqg3mav9537ypl6ww82-python3-3.11.9-env/bin/python
python is /nix/store/pgb120fb7srbh418v4i2a70aq1w9dawd-python3-3.12.5/bin/python
*

Any idea why this could be? I don't have Python installed at the OS level:

❯ python --version
The program 'python' is currently not installed. It is provided by
several packages. You can install it by typing one of the following:

It's even easier to see the issue in this PR, which only bumps nixpkgs and sets the global repo Python to pkgs.python311.

22:44:49
5 Sep 2024
@vengmark2:matrix.orgl0b0

Or even easier than that, check out master and apply this diff:

diff --git a/python.nix b/python.nix
index 2c252db..64d5494 100644
--- a/python.nix
+++ b/python.nix
@@ -1,2 +1,2 @@
 {pkgs}:
-pkgs.python3
+pkgs.python310

With the old version of nixpkgs it builds, you get both Python 3.10 and 3.11 in the resulting shell.

03:48:18
@vengmark2:matrix.orgl0b0 On a related note, How to figure out which part of a derivation is pulling in a specific store path? 20:15:13
@vengmark2:matrix.orgl0b0 Hmh, after a bit of manual shenanigans it looks like all of black, check-jsonschema, gitlint, and nbqa pull in the Python executable. Dang. But also, nothing to do with poetry2nix. 20:31:13
@vengmark2:matrix.orgl0b0 * Hmh, after a bit of manual shenanigans it looks like all of black, check-jsonschema, gitlint, and nbqa pull in the Python executable. Dang. But also, nothing to do with poetry2nix. But now I need to wire a bunch of packages to the same Python I use in the poetry2nix package set, otherwise I can't run things like mypy. 20:38:14
@vengmark2:matrix.orgl0b0 I've tried to instead patch the third party packages to support Python 3.12, but now I'm running into another issue with GDAL: "error: value is null while a set was expected" because nativeBuildInputs is null somehow. 21:55:39
@vengmark2:matrix.orgl0b0 * I've tried to instead patch the third party packages to support Python 3.12, but now I'm running into another issue with GDAL: "error: value is null while a set was expected" because nativeBuildInputs is null somehow. Using poetry2nix 2024.9.285936. 21:57:09
@vengmark2:matrix.orgl0b0 Excluding that part of the derivation, I run into yet another issue: "ModuleNotFoundError: No module named '_cffi_backend'" when building argon2-cffi-bindings. I've tried adding cffi to buildInputs, nativeBuildInputs, and propagatedBuildInputs, with no change in the error message. 22:28:57
@vengmark2:matrix.orgl0b0 Turns out argon2-cffi-bindings doesn't build on Python 3.12 22:56:19
@vengmark2:matrix.orgl0b0 * Turns out argon2-cffi-bindings doesn't build on Python 3.12, which in turn breaks jedi and then numpy. 22:59:22
@vengmark2:matrix.orgl0b0OK, I give up. I've been trying to update nixpkgs for two days now, and I keep getting new and weird error messages.23:53:01
6 Sep 2024
@tdjordan:matrix.orgThom Jordan joined the room.18:21:39

Show newer messages


Back to Room ListRoom Version: 6