organist icon indicating copy to clipboard operation
organist copied to clipboard

organist.import_nix doesn't work with outputs from the current flake

Open mboes opened this issue 1 year ago • 2 comments

Say you have a flake output called foo, such that the following works:

$ nix build .#foo

I would expect organist.import_nix ".#foo", say in a project.ncl, to evaluate to a Nix path. Actual:

error: Missing input "..foo"

This is despite the fact that https://github.com/nickel-lang/organist/blob/main/lib/nix-interop/derivation.ncl#L258-L262 claims:

This follows the same search rules as the nix build cli, namely that the library will consider the first valid values within: - InputPath - "packages".system.InputPath - "legacyPackages".system.InputPath

mboes avatar Jan 28 '24 22:01 mboes

Mh, I see how that comment can be misleading (and the error message a bit too, although that should be fixed by 7e6c7f8a1284e00da55d2d27bdc6890e48b9af1e).

The search rules are a purely Nix-language level thing, they don't interact with the command-line – and .#foo only makes sense at the command-line. The current flake is referred to as self in the language — so you want organist.import_nix "self#foo".

I'll try to improve the wording to make this more explicit

thufschmitt avatar Jan 29 '24 17:01 thufschmitt

I see. Shows my ignorance of most things flakes. Like you say though, if the quality of diagnostics could be improved that would be great.

mboes avatar Feb 07 '24 14:02 mboes