-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Milestone
Description
Describe the bug
nix store add-file
can't add a file from stdin.
Steps To Reproduce
$ echo hi | ./outputs/out/bin/nix store add-file /dev/stdin
error: ca hash mismatch importing path '/nix/store/c3cgy7lnh6ni2kqvsxqblyz2pzb2hl2a-stdin';
specified: sha256:1r3v22qkypccqifzbww5lrn6hf1chi23m6zzkyvb8bvg457nxslq
got: sha256:0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
It seems that it can add the empty file, but only the empty file
$ true | nix store add-file /dev/stdin
/nix/store/gzm5hrm4a70c5kard6v2792hpk07b1jy-stdin
Expected behavior
Print a store path.
Probably it needs to traverse the stream twice, which doesn't work for a pipe.
Three solutions
- write to temporary file first. This won't go out of memory, but can be expensive
- read everything into memory first.
- any of the above, but only when the fd doesn't allow seeking
Don't we have a Sink or Source that retains the contents in memory until it reaches a certain size and then writes it all to disk? If not, we should.
nix-env --version
output
Happens with my system nix
$ nix-env --version
nix-env (Nix) 2.11.1
.. and also with a recently built master
nix 2.14pre
Additional context
Priorities
Add 👍 to issues you find important.
benradf and nagy
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In discussion