1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 00:16:11 -04:00
This commit is contained in:
Théophane Hufschmitt 2024-10-15 08:58:54 +02:00 committed by GitHub
commit 87de5aff8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View file

@ -60,6 +60,13 @@ void PosixSourceAccessor::readFile(
if (fstat(fromDescriptorReadOnly(fd.get()), &st) == -1) if (fstat(fromDescriptorReadOnly(fd.get()), &st) == -1)
throw SysError("statting file"); throw SysError("statting file");
if (!S_ISREG(st.st_mode)) {
std::string fileContent = nix::readFile(path.abs());
sizeCallback(fileContent.size());
sink(fileContent);
return;
}
sizeCallback(st.st_size); sizeCallback(st.st_size);
off_t left = st.st_size; off_t left = st.st_size;

View file

@ -44,6 +44,7 @@ nix_tests = \
fetchGitSubmodules.sh \ fetchGitSubmodules.sh \
fetchGitVerification.sh \ fetchGitVerification.sh \
readfile-context.sh \ readfile-context.sh \
readfile-stdin.sh \
nix-channel.sh \ nix-channel.sh \
recursive.sh \ recursive.sh \
dependencies.sh \ dependencies.sh \

View file

@ -0,0 +1,3 @@
source common.sh
[[ $(echo yay | nix eval --raw --impure --expr 'builtins.readFile "/dev/stdin"') = yay ]]