Open anoadragon453 opened 3 weeks ago
I'm not familiar with the tasks implementation, but something tells me we have an issue in the graph traversal somewhere, ie. we're not picking up indirect dependencies of enterShell
+ the ordering appears reversed.
I think I've found the issue. We'll discuss it next week and have a fix out promptly.
After a search on GitHub, I have found a way to make this work. Credits go to this commit. It's a matter of defining both before
and after
for the task. Personally, I don't use Poetry, but only rely on venv with a requirements.txt file. This is how I've patched ruff:
devenv.nix
(...)
languages.python = {
enable = true;
version = "3.12.7";
venv = {
enable = true;
requirements = ./requirements.txt;
};
};
tasks = {
# Patch ruff to make it runnable
"venv:patchelf" = {
exec = "${lib.getExe pkgs.patchelf} --set-interpreter ${pkgs.stdenv.cc.bintools.dynamicLinker} $VIRTUAL_ENV/bin/ruff";
after = [ "devenv:python:virtualenv" ]; # Runs after this
before = [ "devenv:enterShell" ]; # Runs before this
};
};
Describe the bug I'm attempting to run a small script after
poetry install
completes in my repo.poetry install
downloads some binaries that are dynamically linked againstld
, and thus do not work on NixOS. I'm trying to automatically runpatchelf
afterpoetry install
completes in order to patchruff
, thus allowing NixOS developers to not have to worry about doing it themselves or manually running a command after eachpoetry install
.Here is my devenv module:
I first tried to put the above
patchelf; autoPatchelf
invocation inenterShell
, but that failed aspoetry install
runs after whatever a devenv module defines inenterShell
. Meaningpatchelf
would be called, and thenruff
would be downloaded bypoetry install
.Interestingly,
poetry install
is defined as a task that apparently runs afterenterShell
:https://github.com/cachix/devenv/blob/fa53082e82e90bd378cf850ca3d2b6892eebc77e/src/modules/languages/python.nix#L457-L486
I attempted all sorts of combinations of trying to get my task to run after both
"devenv:enterShell"
and"devenv:python:poetry"
, but to no avail. If I do:then my task runs, but does so before the
poetry install
, so fails asruff
does not exist:however, if I do the logical thing and:
my task doesn't run at all:
So I'm at a loss. This is using a flake, not
devenv.nix/yaml/lock
.To reproduce
My devenv module can be found here, along with all other relevant files: https://github.com/element-hq/nix-flakes/blob/anoa/devenv_repro/project-flakes/sygnal/module.nix
Version
Using flakes, devenv v1.3.1.