Skip to content

nix-store --restore on the result of nix-store --dump does not work #951

@adnelson

Description

@adnelson

The nix manual states that

A Nix archive can be unpacked using nix-store --restore.

However, this does not seem to be the case. I started with the following file:

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "test1";
  buildCommand = "echo hello > $out";
}

I built this with nix and created a dump file:

$ nix-build test.nix
these derivations will be built:
  /nix/store/giiccnygmwnls3zhs7pibx89xfl0arya-test1.drv
building path(s) ‘/nix/store/ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1’
/nix/store/ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1
$ nix-store --dump /nix/store/ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1 > dump

I then copied this dump file to a virtual machine with a fresh installation of nix (running on CentOS 7). When I attempt to restore it, the command succeeds and the store object is created:

$ cat dump | nix-store --restore /nix/store/ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1
$ ls /nix/store | grep 'test1$'
ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1

However, the created store object does not appear in the SQLite database, and nix-store does not seem to be able to do anything with the file:

$ sqlite3 /nix/var/nix/db/db.sqlite
sqlite> select * from ValidPaths where path = '/nix/store/ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1';
(nothing)
$ nix-store -q /nix/store/ma6agnfk5103hfrr4v4hgd46rasn0hxc-test1
error: path ‘/nix/store/wvnxq72s8jabgl9jv0whdff2ijsxp90b-test1’ does not exist and cannot be created

Apparently it is not sufficient to simply perform a nix-store --restore on the result of a nix-store --dump. I assume that there are subsequent steps required to load the restored object and its metadata into the nix database. This is probably just a documentation issue, because nix-copy-closure is able to copy objects without trouble. However, it's not really clear how to do manual object transfer using dump/restore, without doing the database part manually (which certainly isn't desirable).

Also, when I attempt to do a --restore on nixos, I get Read-only file system errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions