is it allowed to dynamically infer dependencies fo...
# general
f
is it allowed to dynamically infer dependencies for a target which lies outside of the project root where pants is run?
w
somewhat… it’s necessary to do it very cautiously, and it requires some abstraction leaks.
because we don’t have https://github.com/pantsbuild/pants/issues/10842, there is no built in way to grab a file from an absolute path. to do it, you need to: 1. mark your
@rule
uncacheable, either via its output type being
EngineAwareReturnType.cacheable=False
, or by marking
@_uncacheable_rule
2. use Python’s file API to load the file
and even then: it cannot have a declared
dependency
in the
./pants dependencies
sense, because you won’t be able to create a target for something outside the repo.
f
🤔
maybe i need to think about this another way .. but i might as well step back a few
i’m looking for a way to integrate nix with pants — i.e, i want to let nix handle builds of software and assist in providing the shell setup to run certain commands, or ensure certain tools are in PATH .. similar to shell commands, i want tools to be provided/built by nix … my main problem is i want to cache the “result” of nix expressions while tracking the dependencies with pants so it knows when the deps of the nix expressions has been changed if that makes any sense at all — don’t know if you’re familiar with nix or how it works
and just now — if i can just do everything with flakes, i’ll get a lockfile — which can likely be used for the exact purpose i’m looking for, where it can be a regular dependency within the project …
w
hm… yea, some support for
nix
would be great. i expect that there are at least two aspects there though: 1.
PATH
entries from nix 2. other absolute files from nix
1. is subject to https://github.com/pantsbuild/pants/issues/10769 and https://github.com/pantsbuild/pants/issues/12203 , because we don’t currently deeply fingerprint
PATH
entries
2. is more like what i mentioned above
👍 1
f
i’ll try my flake lockfile approach first and see if i can make that work as a starter
s
Hi @freezing-lamp-12123 did you manage to get pants working in nix shell? if so, maybe can you share any relevant
.nix
excerpts?