Fixes <http://bugs.gnu.org/19044>.
* nix/guix-register/guix-register.cc (register_validity): Change the (optimize
&& prefix.empty ()) condition to just (optimize). Change settings.nixStore
around the loop. Prepend PREFIX to the argument passed to 'optimisePath'.
* tests/guix-register.sh: Use 'guix-register -p' with duplicate files, and
make sure they are deduplicated on the target. Adjust existing tests.
* tests/guix-register.sh: Remove redundant $new_store in $NIX_STATE_DIR,
introduced in 689142cd ("guix-register: Add '--state-directory'
parameter.") Reported by Eric Bavier <ericbavier@gmail.com> and
Alen Skondro <askondro@gmail.com>.
* nix/guix-register/guix-register.cc (GUIX_OPT_STATE_DIRECTORY): New
macro.
(parse_opt): Honor it.
* tests/guix-register.sh: Add test with '--state-directory'.
* guix/store.scm (register-path): Add #:state-directory parameter.
Reported by Nikita Karetnikov <nikita@karetnikov.org>
and Pierre-Antoine Rault <par@rigelk.eu>.
* test-env.in: Change 'NIX_LOG_DIR' in accordance with f5768af.
* tests/guix-register.sh: Likewise for 'NIX_LOG_DIR' and 'NIX_DB_DIR'.
* nix/guix-register/guix-register.cc (register_validity): Leave
'info.path' unmodified when PREFIX is empty.
(main): Call 'settings.processEnvironment' early on.
Leave 'settings.nixStore' unmodified when PREFIX is empty.
* nix/guix-register/guix-register.cc (prefix): New variable.
(parse_opt): Use it.
(register_validity): Change 'info.path' to the final store name.
Hash the final under its real path.
* tests/guix-register.sh: Adjust the contents of $closure accordingly.
Rename 'NIX_LOCALSTATE_DIR' to 'NIX_STATE_DIR'. Don't try to call
'valid-path?'. Add test using 'sqlite3'.