Skip to content
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

Implement top-level __findFile #248

Closed
jwiegley opened this issue Apr 28, 2018 · 3 comments
Closed

Implement top-level __findFile #248

jwiegley opened this issue Apr 28, 2018 · 3 comments
Labels
good first issue Suggested for someone who is not yet familiar with the codebase help wanted When someone explicitly requests for help

Comments

@jwiegley
Copy link
Member

No description provided.

@jwiegley jwiegley added this to the BayHac 2018 milestone Apr 28, 2018
@jwiegley jwiegley added the help wanted When someone explicitly requests for help label Apr 28, 2018
@shlevy shlevy added the good first issue Suggested for someone who is not yet familiar with the codebase label Apr 29, 2018
@jwiegley jwiegley removed this from the BayHac 2018 milestone Apr 30, 2018
@drets
Copy link
Contributor

drets commented May 17, 2018

If it is still relevant I would like to try to tackle it.

Should it work something like this?

hnix:master* λ ./dist/build/hnix/hnix --eval --expr "builtins.findFile nixpkgs/default.nix"
/home/drets/src/dots/channels/nixpkgs/default.nix

hnix:master* λ ./dist/build/hnix/hnix --eval --expr "builtins.findFile nixpkgs/blah.nix"
error: file 'nixpkgs/blah.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

@shlevy
Copy link
Member

shlevy commented May 17, 2018

@drets No, findFile takes an explicit set corresponding to the NIX_PATH. nix-instantiate --eval -E builtins.nixPath --strict can show you what that argument looks like, basically it's a list of sets, where each set has a path attribute and an optional prefix. Given prefix = "foo" and path = /bar, <foo/baz> will resolve to /bar/baz. Given no prefix, or an empty string, and path = /bar, and given /bar/foo exists, <foo/baz> will resolve to /bar/foo/baz

@drets
Copy link
Contributor

drets commented May 17, 2018

@shlevy, thank you.

It seems, I figured out how it works:

~ λ nix-instantiate --eval -E "builtins.nixPath" --strict
[ { path = "/home/drets/src/dots/nixos/configuration.nix"; prefix = "nixos-config"; } { path = "/home/drets/src/dots/channels"; prefix = ""; } { path = "/nix/store/2xzhrn49hzcpkg72sgqh6qdx0klckssv-nix-2.0/share/nix/corepkgs"; prefix = "nix"; } ]
~ λ nix-instantiate --eval -E 'builtins.findFile builtins.nixPath "nixpkgs/default.nix"' --strict
/home/drets/src/dots/channels/nixpkgs/default.nix
~ λ nix-instantiate --eval -E 'builtins.findFile builtins.nixPath "nixos-config"' --strict
/home/drets/src/dots/nixos/configuration.nix
~ λ nix-instantiate --eval -E 'builtins.findFile builtins.nixPath "nixpkgs/blah.nix"' --strict
error: file 'nixpkgs/blah.nix' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:1

drets added a commit to drets/hnix that referenced this issue May 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Suggested for someone who is not yet familiar with the codebase help wanted When someone explicitly requests for help
Projects
None yet
Development

No branches or pull requests

3 participants