-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
New builtin: pathType #3096
Comments
I marked this as stale due to inactivity. → More info |
I closed this issue due to inactivity. → More info |
I would like to reopen this issue. The current implementation has a significant drawback. In pure evaluation mode (flakes) it is AFAIK currently impossible to get the type for a top level store path. For example,
since it tries to read the whole |
Most of the time, it's possible to check the type of the store path in the builder that uses that information. For example, don't do runCommand "foo" { } ''
${optionalString (pathType dep == "directory") ''
echo dep is a directory
''}
'' but instead do runCommand "foo" { } ''
if [[ -d ${dep} ]]; then
echo dep is a directory;
fi
'' |
Unfortunately, this doesn't work for me (and probably won't work for everybody). There are cases, where Also, IMHO, it doesn't matter whether getting the I am currently working around this issue by adding an extra directory level to my flake, so I am not too invested in this issue, but I still think, that this ought to work. |
Right, it used to be that you could just avoid putting your project sources in the store (except for derivation sources, by necessity). I hope #6530 makes that work a little better, but I don't assume it does. Reopening. |
+1 I ran into this as well |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-16-nix-team-meeting-minutes-17/24120/1 |
Fixed by #7447 |
@RuRo Perhaps we should consider again |
I'm proposing to add a new
builtins.pathType
that returns the node type, similar to the values returned bybuiltins.readDir
.Motivation
Avoid having to read a directory when all you need is a single path's node type.
Spec
Like
builtins.pathExists
, its argument is a path or string that may or may not exist on the filesystem.Given argument
p
return value isnull
when the pathp
does not point to an existing filesystem node(builtins.readDir (dirOf p))."$(baseNameOf p)"
, such as "directory", "regular", "symlink"Advantages
/nix/store
)readDir (dirOf p)
may not be allowed by dir permissionslorri
The text was updated successfully, but these errors were encountered: