!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

316 Members
https://github.com/nix-community/poetry2nix59 Servers

Load older messages


SenderMessageTime
5 Nov 2023
@adis:blad.isadisbladisYes and no..03:45:52
@adis:blad.isadisbladisNixpkgs is stuck with it's crummy manual packaging, and I don't see any way to push any kinda sanity forward there03:46:27
@k900:0upti.meK900Because that way we can just point at the out-of-tree thing and say "do you want to simply build your own thing? use that"03:46:38
@k900:0upti.meK900
In reply to@adis:blad.is
Nixpkgs is stuck with it's crummy manual packaging, and I don't see any way to push any kinda sanity forward there
I think there's value in unvendoring dependencies the way nixpkgs does
03:47:04
@adis:blad.isadisbladisWe're stuck with poorly translating upstream package definitions to nix and losing fidelity in the process03:47:05
@k900:0upti.meK900But I also don't think most people that just want to ship stuff should go that route03:47:20
@adis:blad.isadisbladis
In reply to @k900:0upti.me
I think there's value in unvendoring dependencies the way nixpkgs does
Absolutely, there is very different needs for packaging stuff out of tree and in tree
03:47:48
@k900:0upti.meK900Like, it's very much a distribution thing03:47:55
@adis:blad.isadisbladisBut like, why do we poorly translate pyproject.toml files into nix03:48:00
@k900:0upti.meK900Because we can't do IFD well, mostly?03:48:17
@k900:0upti.meK900Like I think pyproject.nix would be great in nixpkgs03:48:35
@k900:0upti.meK900If we figure out a way to do IFD without exploding03:48:48
@adis:blad.isadisbladisWhat I mean is, why is nixpkgs python packages not just a pyproject.toml dumped in tree03:48:51
@adis:blad.isadisbladis
In reply to @k900:0upti.me
Like I think pyproject.nix would be great in nixpkgs
It doesn't use IFD at all
03:49:04
@k900:0upti.meK900Well it would if the pyproject.toml comes from the upstream source03:49:17
@adis:blad.isadisbladisWhat I mean is, instead of having a default.nix in tree we'd have pyproject.toml in tree03:49:27
@adis:blad.isadisbladisThe update process would literally be to download the upstream one and dump it03:49:46
@k900:0upti.meK900I kinda like that, but I'm also kinda worried about how to encode the fixups03:50:36
@k900:0upti.meK900Which we're going to need a lot of03:50:39
@k900:0upti.meK900I'm actually about to run myself into a much similar problem with KDE6 stuff03:51:00
@k900:0upti.meK900Because I really want to generate most of it from upstream metadata03:51:08
@k900:0upti.meK900But I'm not sure what a good API for adding fixups on top would be03:51:22
@adis:blad.isadisbladis

If you'd take the pyproject.nix approach with an abstract project representation and renderers you could do something like

 let 
  project = load ./pyproject.toml;
  attrs = render python3 project;
attrs // {
  buildInputs = attrs.buildInputs ++ [ pkgs.openssl ];
}
03:53:28
@adis:blad.isadisbladisOr something along those lines03:53:35
@adis:blad.isadisbladis *

If you'd take the pyproject.nix approach with an abstract project representation and renderers you could do something like

 let 
  project = load ./pyproject.toml;
  attrs = render python3 project;
in
python3.buildPythonPackage (attrs // {
  buildInputs = attrs.buildInputs ++ [ pkgs.openssl ];
})
03:54:05
@adis:blad.isadisbladis *

If you'd take the pyproject.nix approach with an abstract project representation and renderers you could do something like

 let 
  project = load ./pyproject.toml;
  attrs = render python3 project;
in
python3.buildPythonPackage (attrs // {
  buildInputs = attrs.buildInputs ++ [ pkgs.openssl ];
})
03:55:34
@adis:blad.isadisbladisBut I think that 90% of the time (just a number pulled out of thin air) you wouldn't need fixups03:58:07
6 Nov 2023
@adis:blad.isadisbladis

Thinking a bit out loud here about a possible interface for lock files:

{ lib, pkgs, poetry2nix, pyproject }:
let
  # Stub attrs, not yet implemented
  pdm = { };
  overlays = { };

  # Use project abstraction from pyproject.nix
  project = pyproject.project.loadPyproject {
    pyproject = lib.importTOML ./pyproject.toml;
  };

  # Python packages overlay
  overlay = let
    # Create an overlay from pdm.lock
    pdmPackages = pdm.mkOverlay {
      pyproject = lib.importTOML ./pyproject.toml;
      pdmLock = lib.importTOML ./pdm.lock;
    };
    # Pdm.lock is not having PEP-517 build systems locked, use overrides from poetry2nix
    pdmWithBuild = overlays.intersect pdmPackages poetry2nix.overlays.build-systems;
  # Only apply build system overrides to packages that actually need them (packages created by the overlay generator)
  in overlays.intersect pdmPackages poetry2nix.build-systems;

  # Create an overriden interpreter
  python = pkgs.python3.override {
    # Note the self argument.
    # It's important so the interpreter/set is internally consistent.
    self = python;
    packageOverrides = overlay;
  };

  # Render buildPythonPackage with our overriden interpreter
  attrs = pyproject.lib.renderers.buildPythonPackage { inherit python project; };

in python.pkgs.buildPythonPackage attrs
01:04:38
@adis:blad.isadisbladis *

Thinking a bit out loud here about a possible interface for lock files (cross post from #pyproject.nix:blad.is ):

{ lib, pkgs, poetry2nix, pyproject }:
let
  # Stub attrs, not yet implemented
  pdm = { };
  overlays = { };

  # Use project abstraction from pyproject.nix
  project = pyproject.project.loadPyproject {
    pyproject = lib.importTOML ./pyproject.toml;
  };

  # Python packages overlay
  overlay = let
    # Create an overlay from pdm.lock
    pdmPackages = pdm.mkOverlay {
      pyproject = lib.importTOML ./pyproject.toml;
      pdmLock = lib.importTOML ./pdm.lock;
    };
    # Pdm.lock is not having PEP-517 build systems locked, use overrides from poetry2nix
    pdmWithBuild = overlays.intersect pdmPackages poetry2nix.overlays.build-systems;
  # Only apply build system overrides to packages that actually need them (packages created by the overlay generator)
  in overlays.intersect pdmPackages poetry2nix.build-systems;

  # Create an overriden interpreter
  python = pkgs.python3.override {
    # Note the self argument.
    # It's important so the interpreter/set is internally consistent.
    self = python;
    packageOverrides = overlay;
  };

  # Render buildPythonPackage with our overriden interpreter
  attrs = pyproject.lib.renderers.buildPythonPackage { inherit python project; };

in python.pkgs.buildPythonPackage attrs
01:05:06
@adis:blad.isadisbladis cc K900 ⚡️ 01:05:19

Show newer messages


Back to Room ListRoom Version: 6