!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

304 Members
https://github.com/nix-community/poetry2nix55 Servers

Load older messages


SenderMessageTime
5 Jan 2022
@grahamc:nixos.org@grahamc:nixos.orgchanged room power levels.15:09:02
Room Avatar Renderer.15:09:04
@grahamc:nixos.org@grahamc:nixos.org 👍️should be all set adisbladis ! 15:09:21
@mic92:nixos.devMic92 left the room.16:46:19
@averagechris:matrix.orgaveragechris joined the room.22:08:31
7 Jan 2022
@elgert:matrix.orgelgert joined the room.04:04:09
10 Jan 2022
@manveru:matrix.orgmanveru joined the room.13:50:03
11 Jan 2022
@aciceri:nixos.devzrsk joined the room.19:15:53
@aciceri:nixos.devzrsk

Hi,
I'm trying to understand how to use poetry2nix but I've this poroblem, this is my current flake.nix:

{
  description = "My Python application";

  inputs = {
    nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
    flake-utils-plus.url = github:gytis-ivaskevicius/flake-utils-plus/v1.3.1;
  };

  outputs = { self, nixpkgs, flake-utils-plus }:
    flake-utils-plus.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        caseGeneratorApp = pkgs.poetry2nix.mkPoetryEnv {
          projectDir = ./case;
          editablePackageSources = {
            src = ./case/src;
          };
        };

        packageName = "case_generator";
      in
      {

        defaultPackage = caseGeneratorApp;
        devShell = pkgs.mkShell {
          name = "development";
          buildInputs = [
            caseGeneratorApp
          ];
        };
      });
}

When I enter in the development shell withnix develop I get the scripts exposed by poetry and configured in the pyproject.toml in my PATH, and I can correctly execute them. But if I edit these sources (in ./case/src/) it makes no difference. I've to exit and re-enter in the shell to make the changes work.

Am I doing things correctly? If someone know a simple and working flake using poetry2nix I would be happy to take a look.

Thank you

23:48:04
@adis:blad.isadisbladis
In reply to @aciceri:nixos.dev

Hi,
I'm trying to understand how to use poetry2nix but I've this poroblem, this is my current flake.nix:

{
  description = "My Python application";

  inputs = {
    nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
    flake-utils-plus.url = github:gytis-ivaskevicius/flake-utils-plus/v1.3.1;
  };

  outputs = { self, nixpkgs, flake-utils-plus }:
    flake-utils-plus.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        caseGeneratorApp = pkgs.poetry2nix.mkPoetryEnv {
          projectDir = ./case;
          editablePackageSources = {
            src = ./case/src;
          };
        };

        packageName = "case_generator";
      in
      {

        defaultPackage = caseGeneratorApp;
        devShell = pkgs.mkShell {
          name = "development";
          buildInputs = [
            caseGeneratorApp
          ];
        };
      });
}

When I enter in the development shell withnix develop I get the scripts exposed by poetry and configured in the pyproject.toml in my PATH, and I can correctly execute them. But if I edit these sources (in ./case/src/) it makes no difference. I've to exit and re-enter in the shell to make the changes work.

Am I doing things correctly? If someone know a simple and working flake using poetry2nix I would be happy to take a look.

Thank you

That's because of how flakes work re purity. In a flake evaluation ./foo doesn't refer to the local path, but the path copied to the store.
23:52:29
@adis:blad.isadisbladisIt's not a poetry2nix thing, it's a flakes thing.23:52:40
12 Jan 2022
@aciceri:nixos.devzrskAhh, I understand. What do you suggest me then? What would be the correct way to use a flake to manage a development flow like this?00:02:20
@adis:blad.isadisbladis
In reply to @aciceri:nixos.dev
Ahh, I understand. What do you suggest me then? What would be the correct way to use a flake to manage a development flow like this?

I've seen people using --impure combined with environment variables to reference paths outside of the store.
That could work.

I'm not a flakes user so I might not be of too much help.

00:03:47
@aciceri:nixos.devzrsk Thank you for the hint, I'll try.
Do you know any project using flake and poetry2nix as reference?
00:31:16
@averagechris:matrix.orgaveragechris zrsk: I have been packaging a few python apps as nix flakes. I'm no expert, but what's worked for me with editable installs is mkPoetryEnv as devShell instead of mkShell with the env as an input 00:33:43
@averagechris:matrix.orgaveragechris

here is a copy paste of an example from one of the apps I packaged last week

      devShell = (pkgs.poetry2nix.mkPoetryEnv {
        projectDir = ./.;
        editablePackageSources.YOUR_APP = ./YOUR_SRC_DIR;
      }).env.overrideAttrs (old: {
        propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ]) ++ nativeDependencies;
        shellHook = (old.shellHook or "") + ''
          export GDAL_LIBRARY_PATH="${pkgs.gdal}/lib/libgdal.so"
          export GEOS_LIBRARY_PATH="${pkgs.geos}/lib/libgeos_c.so"
        '';
        buildInputs = extraDevDependencies;
      });
00:36:11
@aciceri:nixos.devzrsk averagechris: thank you! I'll definitely try this approach, I don't like the idea to use --impure 00:39:17
@averagechris:matrix.orgaveragechrisGood luck and let us know if you learn anything interesting :)00:39:47
@adis:blad.isadisbladis
In reply to @averagechris:matrix.org
zrsk: I have been packaging a few python apps as nix flakes. I'm no expert, but what's worked for me with editable installs is mkPoetryEnv as devShell instead of mkShell with the env as an input
I don't understand how that would work, but if it does I'm very interested in knowing more...
00:42:56
@averagechris:matrix.orgaveragechrisI'm using lorri that might be it?00:44:26
@averagechris:matrix.orgaveragechrisso maybe I'm just slow enough so that it reevaluates everything00:44:47
@adis:blad.isadisbladisLorri doesn't have flakes support afaik?00:45:39
@averagechris:matrix.orgaveragechrisyou have to make a compatible shell.nix00:46:03
@adis:blad.isadisbladisRight, then the evaluation model is different00:46:14
@adis:blad.isadisbladisFlakes enforces hermetic evaluation by copying everything to the store00:46:35
@adis:blad.isadisbladisWhich changes the semantics of paths00:46:49
@averagechris:matrix.orgaveragechrisah right and so when lorri invokes the shell.nix those semantics are not in place00:47:23
@averagechris:matrix.orgaveragechris zrsk: that's important context ^ 00:47:33
@adis:blad.isadisbladisExactamundo00:47:34
@averagechris:matrix.orgaveragechrisTotally makes sense I didn't even think about that.00:47:54

Show newer messages


Back to Room ListRoom Version: 6