12 Jun 2024 |
jameswarren (James Warren) | Yes I am. Looking at the source code, it looks somewhat understandable - I was planning on spending more time pondering it to either understand how it's to be used or how I could modify it. It's not my most pressing problem at the moment, though. 🤷 | 03:53:45 |
13 Jun 2024 |
| ixxie joined the room. | 08:18:15 |
ixxie | Hey folks, I'm new to poetry2nix and trying to get my first flake going for a python backend in a monorepo.
The flake quickstart example has a default app output as follows:
apps.${system}.default = {
type = "app";
program = "${myapp}/bin/some_script";
};
But I would like to output multiple scripts as different commands. How would I go about it? I thought I could just do apps.${system}.command_name but it complains:
error: flake 'git+file:///home/ixxie/myapp?dir=backend' does not provide attribute 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux
| 08:20:09 |
ixxie | ah right, need to run it as an app, not build it | 08:37:21 |
ixxie | I'm not sure what to make of this... here is the flake for the backend (it's in ${monorepo}/backend ):
{
description = "MyApp Backend - Python, Uvicorn & FastAPI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, poetry2nix }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
# create a custom "mkPoetryApplication" API function that under the hood uses
# the packages and versions (python3, poetry etc.) from our pinned nixpkgs above:
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
myapp = mkPoetryApplication { projectDir = ./.; };
in
{
apps.${system}.backend = {
type = "app";
program = "${myapp}/bin/backend";
};
};
}
But I get the following error:
warning: Git tree '/home/ixxie/myapp' is dirty
error:
… while calling a functor (an attribute set with a '__functor' attribute)
at /nix/store/lpqygnph8c5l7ajkmqr4rff0pvkfz1f6-source/default.nix:407:13:
406|
407| app = py.pkgs.buildPythonPackage (
| ^
408| passedAttrs // inputAttrs // {
… while evaluating a branch condition
at /nix/store/dydg48djlykksz8cxq0xjplyxpa9pvf4-source/pkgs/development/interpreters/python/python-packages-base.nix:28:7:
27| in
28| if builtins.isAttrs result then result
| ^
29| else if builtins.isFunction result then {
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: expected a set but found null: null
| 08:44:08 |
ixxie | How do I control the name of the package created with mkPoetryApplication and installed with nix profile install ? | 11:29:47 |
TyberiusPrime (smilodon inopinatus) | In reply to @ixxie:matrix.org How do I control the name of the package created with mkPoetryApplication and installed with nix profile install ? I thought it was taken from pyproject.toml? the source indicate that this is true | 12:08:17 |
TyberiusPrime (smilodon inopinatus) | adisbladis: Hi, are you still working on poetry2nix? | 12:09:01 |
TyberiusPrime (smilodon inopinatus) | ixxie: I think you just call mkPoetryApplication and then they're all in ./results/bin | 12:09:58 |
ixxie | In reply to @tyberius_prime:matrix.org I thought it was taken from pyproject.toml? the source indicate that this is true I've set the name in pyproject.toml , and set pname in mkPoetryApplication but when I run nix profile install .#package-name but then I still get something like this:
> nix profile list
Name: path/from/git/root/to/flake
Flake attribute: packages.x86_64-linux.default
Original flake URL: git+file:///home/ixxie/project?dir=path/from/git/root/to/flake
Locked flake URL: git+file:///home/ixxie/project?dir=path/from/git/root/to/flake
Store paths: /nix/store/4r112qhr7f3vsxj3jx4ynvyb8560vjxf-python3.11-cli-0.1
| 12:15:12 |
ixxie | I mean it installs well, I'm just wondering why the name is like this | 12:16:43 |
TyberiusPrime (smilodon inopinatus) | well, the name (pname + version) ends up in the store path, which I giuess is where the python3.11-cli comes from (cli being set in your pyproject.toml).
I suppose you want to change 'Name:'? | 12:16:49 |
ixxie | In reply to @tyberius_prime:matrix.org well, the name (pname + version) ends up in the store path, which I giuess is where the python3.11-cli comes from (cli being set in your pyproject.toml).
I suppose you want to change 'Name:'? yep, because that would be how I refer to it when managing it with nix profile | 12:17:18 |
TyberiusPrime (smilodon inopinatus) | (I don't use nix profile, so I can't comment on where it's getting the name from.) | 12:17:30 |
TyberiusPrime (smilodon inopinatus) | I mean you can change the flake attribute easily enough, so 'flake attribute' is something you could change, at the price of having to do nix profile install /path/to/flake#name | 12:18:41 |
ixxie | In reply to @tyberius_prime:matrix.org I mean you can change the flake attribute easily enough, so 'flake attribute' is something you could change, at the price of having to do nix profile install /path/to/flake#name yeah the attribute hasn't been an issue | 12:24:42 |
ixxie | thanks anyway | 12:24:45 |
TyberiusPrime (smilodon inopinatus) | no worries | 12:26:41 |
15 Jun 2024 |
| @roastedcheesee:matrix.org joined the room. | 17:32:41 |
@roastedcheesee:matrix.org | hey, how can I override the generated inputs in mkPoetryApplication ? I know I can override the dependencies but I can't manage to add inputs to the package itself
mkPoetryApplication {
projectDir = src;
patches = [ ./salmon.patch ];
overrides = defaultPoetryOverrides.extend (self: super: {
bencoder-pyx = super.bencoder-pyx.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ super.setuptools super.cython ];
});
pyimgurapi = super.pyimgurapi.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ super.poetry ];
});
heybrochecklog = super.heybrochecklog.overridePythonAttrs (old: {
patches = (old.patches or []) ++ [ ./salmon.patch ]; # ffs
buildInputs = (old.buildInputs or []) ++ [ super.setuptools super.poetry ];
});
dottorrent = super.dottorrent.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ super.setuptools ];
});
bs4 = super.bs4.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ super.setuptools ];
});
pyimgur = super.pyimgur.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ super.setuptools ];
});
});
};
this is what I have so far, I tried overriding it together with the other dependencies but it had no effect
| 17:36:02 |
18 Jun 2024 |
| Josefine changed their display name from Jonas Katzke to Josefine. | 07:32:34 |
20 Jun 2024 |
TyberiusPrime (smilodon inopinatus) | Poetry2nix is IDF, right? how do I get a dependency on that IDF?
I'm trying a wild thing, where I teach poetry mercurial by prefetching the mercurial repo (&rev) into the nix store, and rewriting the lock files a bit, but I can only build it in impure mode since even if I stick the fetchhg into the build inputs of the python package, that's not there when poetry2nix does it's thing (and why would it...) | 09:10:10 |
TyberiusPrime (smilodon inopinatus) | hah, all I need to do is overwrite src! | 09:51:06 |
TyberiusPrime (smilodon inopinatus) | of course | 09:51:09 |
| Aaron Steele joined the room. | 16:39:05 |
colonelpanic | Does anyone have any what is going on with libcst?
seems like its not extracting a tar archive that it should be:
error: opening file '/nix/store/201zc10pdd4ls1gmpsmbl710lm0q6ai7-libcst-1.1.0.tar.gz/native/Cargo.lock': Not a directory | 17:00:51 |
Aaron Steele | potentially silly question: how to get keyrings-google-artifactregistry-auth working in mkPoetryEnv ? i include it as a buildInput and it works in the shellHook , but when i add a private source in tool.poetry.source' and try nix-shell`, i get these errors:
building '/nix/store/had00ag5f29zdjwlv5hmmc596cl60sjv-genjax-0.4.0-py3-none-any.whl.drv'...
Reading index https://us-west1-python.pkg.dev/probcomp-caliban/probcomp/simple/genjax/
Traceback (most recent call last):
File "/nix/store/0rzh74dywg10ggl3ds6khsdpc84nbp96-fetch-from-legacy.py", line 82, in <module>
response = urllib.request.urlopen(req, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized
| 17:12:06 |
Aaron Steele | * potentially silly question: how to get keyrings-google-artifactregistry-auth working in mkPoetryEnv ? i include it as a buildInput and it works in the shellHook , but when i add a private source in tool.poetry.source and try nix-shell , i get these errors:
building '/nix/store/had00ag5f29zdjwlv5hmmc596cl60sjv-genjax-0.4.0-py3-none-any.whl.drv'...
Reading index https://us-west1-python.pkg.dev/probcomp-caliban/probcomp/simple/genjax/
Traceback (most recent call last):
File "/nix/store/0rzh74dywg10ggl3ds6khsdpc84nbp96-fetch-from-legacy.py", line 82, in <module>
response = urllib.request.urlopen(req, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized
| 17:12:27 |
Aaron Steele | there was a related issue here, although it's not clear how to use the workaround: https://github.com/nix-community/poetry2nix/issues/672#issuecomment-1744109953 | 17:13:32 |
Aaron Steele | (thanks for any guidance!!) | 17:13:46 |