-
-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using editablePackageSources with flakes #425
Comments
I guess fundamentally an editable package will never work with a pure flake, as the whole concept of pureness means it is not editable. Your pointer helped me. One note, the "PWD" only works when the shell is invoked from the root of the project, so this is a bit of a tripwire. The alternative is to hardcode the path in your home folder into the flake ... also not nice but works as well, so for example
|
This isn't actually an issue in poetry2nix, so I'm gonna close this. |
I agree that this may not be something that can be fixed in poetry2nix but as flakes are supposedly the new standard, some documentation on the README pointing out this issue would be helpful. |
Flakes are not the new standard, they are an experimental feature. With that in mind any sharp edges are up to the user of that experimental feature to deal with. |
sorry, sure - it is an experimental feature. I am new to this, so I try to use it almost exclusively. As the flakes are mentioned on the README, I thought it would be good to at least point to some pitfalls. I certainly spent quite a bit of time with this issue as things didn't work as I hoped. |
Wanted to add my current workaround as a solution. pkgs.poetry2nix.mkPoetryEnv {
projectDir = ./.;
python = pkgs.python39;
editablePackageSources = {
myProject = if builtins.getEnv "PROJECT_DIR" == "" then ./. else builtins.getEnv "PROJECT_DIR";
};
} This way, if the flake is pure, the flake directory is used and copied to the store (being reproducible as flakes intended). If #! /usr/bin/env bash
export PROJECT_DIR=$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")
nix shell --impure $PROJECT_DIR When sourced, it will drop you into the shell environment with editable sources. The bash script assumes your project dir is your flake directory as well and the package is set as the default. |
@hhoeflin Thanks! I think that's a nice solution which causes less friction than only |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/editable-python-environment-with-poetry2nix/44520/2 |
* fix editable nix nix-community/poetry2nix#425 * delete cassettes They've been more trouble than they're worth. Most of the point of this library is to be an API wrapper If my tests fail on live runs I want to know * handle off days Get changed series returns a 409 (why?!) when it's run on a day with no updates * remove pyvcr You're an API wrapper, test the API * remove dependency on pytest-recording
When using poetry2nix in a flake-based project,
editablePackageSources
doesn't seem to work as documented:In this case, the
./.
always references the flake's source that was copied into the store (something like/nix/store/p68s64y2g86wb02rj0am4q4wp4cj8mgs-source
). I found a workaround by doing something like this:This seems to work when running with
--impure
, but is there a better way to do this without relying on the environment variable?The text was updated successfully, but these errors were encountered: