Open Ericson2314 opened 4 years ago
How does it differ from builtins.path
?
Let me write an example of what I am thinking:
builtins.toDir "nix-support" {
"setup-hook" = {
executable = false;
contents = ./pkgs/buils-suport/setup-hooks/foo.sh;
};
}
builtins.path
can't do that, right?
I marked this as stale due to inactivity. → More info
Smells like a lazy tree.
Yeah, this could be implemented as an InputAccessor
, similar to PatchingInputAccessor
, that would synthesize a source tree lazily.
We have
toFile
,readFile
, andreadDir
, this would complete the square. I suppose it would take a attrset of paths and return a store path. Maybe likefilterSource
, we would need some restriction on the input source in case they are a derivation output that needs to be built? (Though I really hope we can turnbuiltins.filterSource
into contents-addresssed derivations when we need to delay them!)This probably can be solved another way in the meantime, but I would use it move the setup hooks common to every stdenv to
$out/nix-support/setup/hook
, that we the awful part of stdenv that tries tosource
an input if it is just a single file can go away.Bad stdenv, bad: https://github.com/NixOS/nixpkgs/blob/2ef110ae64a96c0d16df86f8390cfe0af7ff45dc/pkgs/stdenv/generic/setup.sh#L474-L476
Bare setup hooks: https://github.com/NixOS/nixpkgs/blob/2a19a034313e46134853a655121d45b37ab3cbb6/pkgs/stdenv/generic/default.nix#L55-L69
EDIT: mentioning
toDirectory
for discoverability.toDir
is the consistent name.