daemon: Really enable automatic deduplication by default.

* nix/nix-daemon/guix-daemon.cc (main): Set 'autoStoreOptimise' to
  true.  Add 'printMsg' call.
* tests/derivations.scm ("identical files are deduplicated"): New test.
This commit is contained in:
Ludovic Courtès 2014-08-31 14:43:38 +02:00
parent 79601521fc
commit 44d43c7a85
2 changed files with 29 additions and 0 deletions

View file

@ -249,6 +249,9 @@ main (int argc, char *argv[])
settings.useChroot = false; settings.useChroot = false;
#endif #endif
/* Turn automatic deduplication on by default. */
settings.autoOptimiseStore = true;
argvSaved = argv; argvSaved = argv;
try try
@ -325,6 +328,10 @@ main (int argc, char *argv[])
} }
#endif #endif
printMsg (lvlDebug,
format ("automatic deduplication set to %1%")
% settings.autoOptimiseStore);
printMsg (lvlDebug, printMsg (lvlDebug,
format ("listening on `%1%'") % settings.nixDaemonSocketFile); format ("listening on `%1%'") % settings.nixDaemonSocketFile);

View file

@ -151,6 +151,28 @@ (define prefix-len (string-length dir))
;; the contents. ;; the contents.
(valid-path? %store (derivation->output-path drv))))) (valid-path? %store (derivation->output-path drv)))))
(test-assert "identical files are deduplicated"
(let* ((build1 (add-text-to-store %store "one.sh"
"echo hello, world > \"$out\"\n"
'()))
(build2 (add-text-to-store %store "two.sh"
"# Hey!\necho hello, world > \"$out\"\n"
'()))
(drv1 (derivation %store "foo"
%bash `(,build1)
#:inputs `((,%bash) (,build1))))
(drv2 (derivation %store "bar"
%bash `(,build2)
#:inputs `((,%bash) (,build2)))))
(and (build-derivations %store (list drv1 drv2))
(let ((file1 (derivation->output-path drv1))
(file2 (derivation->output-path drv2)))
(and (valid-path? %store file1) (valid-path? %store file2)
(string=? (call-with-input-file file1 get-string-all)
"hello, world\n")
(= (stat:ino (lstat file1))
(stat:ino (lstat file2))))))))
(test-assert "fixed-output-derivation?" (test-assert "fixed-output-derivation?"
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
"echo -n hello > $out" '())) "echo -n hello > $out" '()))