-
Notifications
You must be signed in to change notification settings - Fork 90
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
Search for imports in NICKEL_PATH #1716
Conversation
core/src/cache.rs
Outdated
let import_paths = std::env::var("NICKEL_PATH") | ||
.map(|paths| paths.split(':').map(PathBuf::from).collect()) | ||
.unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should rather be an argument to Cache::new
and then the actual logic from where to get the path should be up to the particular use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this in Cache::new
required threading them through a lot of things, so I tried out making the import paths mutable after construction. This changes the behavior a little, but I think it might be desirable actually: when running nix export file.nix
, the path "file.nix" is now only searched for in the current directory, and NICKEL_PATH
is only used for finding things that "file.nix" imports.
Edit: also, this will make tests easier to write. I'll add those when I have a little more time. (done)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naive question: is there any rationale behind using an environment variable versus a CLI argument --nickel-path
? Or versus using both? (whatever is the answer, it can be treated in a separate PR anyway)
I think probably it makes sense to have both. Maybe @thufschmitt will have an opinion, since I think he's the one that asked for the env var originally. |
Oh my! This is awesome, it means that we can get rid of the nickel lockfile in Organist. I'm personally mostly interested in the environment variable, but a CLI flag would probably make sense for a number of use-cases. |
This is great! We already have a PoC for nickel-lang/rules_nickel/, which adds |
Here is a proposal for the most basic kind of "package management": a
NICKEL_PATH
environment whose value is a comma-separated list of paths look for imports in. The idea is that if you're usingnpm
, for example, then you set this up to point tonode_modules
and then nickel can find all your imported packages.It works reasonably well with nix also, as long as there are no recursive dependencies. For example, I'm using the following flake to get nickel validation for helix configurations:
I didn't have a good idea for how to test this, given that it requires setting up an environment variable...