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

Can't add a file from stdin #7773

Open
roberth opened this issue Feb 7, 2023 · 2 comments
Open

Can't add a file from stdin #7773

roberth opened this issue Feb 7, 2023 · 2 comments
Labels
bug new-cli Relating to the "nix" command

Comments

@roberth
Copy link
Member

roberth commented Feb 7, 2023

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.

@roberth roberth added bug new-cli Relating to the "nix" command labels Feb 7, 2023
@roberth roberth added this to Nix team Feb 15, 2023
@edolstra edolstra moved this to ⏰ Postponed in Nix team Feb 17, 2023
@fricklerhandwerk
Copy link
Contributor

Triaged in the Nix team meeting 2023-02-17:

  • relevant for stabilsation as a global concern
  • we may or may not want to support pipes
  • have to make a design decision
  • postponed, to be addressed together with other global issues

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-02-17-nix-team-meeting-minutes-33/25624/1

@thufschmitt thufschmitt added this to the CLI Stabilisation milestone Sep 4, 2023
@thufschmitt thufschmitt removed this from Nix team Feb 28, 2024
@thufschmitt thufschmitt moved this from Defined work to In discussion in Nix implementation board Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new-cli Relating to the "nix" command
Projects
Status: In discussion
Development

No branches or pull requests

4 participants