-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
Describe the bug
I had a system where any nix command gives this error:
nix run -v nixpkgs#hello
unpacking 'github:NixOS/nixpkgs/59e69648d345d6e8fef86158c555730fa12af9de?narHash=sha256-IiiXB3BDTi6UqzAZcf2S797hWEPCRZOwyNThJIYhUfk%3D' into the Git cache...
this path will be fetched (0.05 MiB download, 0.24 MiB unpacked):
/nix/store/ikcillnkc5k42229mkf7rw3hs9dzpzlf-hello-2.12.1
error:
… while decoding key named ''
error: key is corrupt
The reason was that I have this in my config: secret-key-files = /etc/nix/private-key which is a private key generated by running [[ -f /etc/nix/private-key ]] || nix-store --generate-binary-cache-key $HOSTNAME-1 /etc/nix/private-key /etc/nix/public-key
But, if the host is terminated while this is happening it can leave empty private and public key files on the disk. Probably we need to fsync the files after writing them or something to make this less likely to happen, or write them to a temp file first before moving.
Expected behavior
We're not left with corrupt key files.
Add 👍 to issues you find important.
rossng