1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-20 23:28:26 -04:00
nix/src/libutil
Eelco Dolstra 0abb3ad537 Allow content-addressable paths to have references
This adds a command 'nix make-content-addressable' that rewrites the
specified store paths into content-addressable paths. The advantage of
such paths is that 1) they can be imported without signatures; 2) they
can enable deduplication in cases where derivation changes do not
cause output changes (apart from store path hashes).

For example,

  $ nix make-content-addressable -r nixpkgs.cowsay
  rewrote '/nix/store/g1g31ah55xdia1jdqabv1imf6mcw0nb1-glibc-2.25-49' to '/nix/store/48jfj7bg78a8n4f2nhg269rgw1936vj4-glibc-2.25-49'
  ...
  rewrote '/nix/store/qbi6rzpk0bxjw8lw6azn2mc7ynnn455q-cowsay-3.03+dfsg1-16' to '/nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16'

We can then copy the resulting closure to another store without
signatures:

  $ nix copy --trusted-public-keys '' ---to ~/my-nix /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16

In order to support self-references in content-addressable paths,
these paths are hashed "modulo" self-references, meaning that
self-references are zeroed out during hashing. Somewhat annoyingly,
this means that the NAR hash stored in the Nix database is no longer
necessarily equal to the output of "nix hash-path"; for
content-addressable paths, you need to pass the --modulo flag:

  $ nix path-info --json /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16  | jq -r .[].narHash
  sha256:0ri611gdilz2c9rsibqhsipbfs9vwcqvs811a52i2bnkhv7w9mgw

  $ nix hash-path --type sha256 --base32 /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16
  1ggznh07khq0hz6id09pqws3a8q9pn03ya3c03nwck1kwq8rclzs

  $ nix hash-path --type sha256 --base32 /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 --modulo iq6g2x4q62xp7y7493bibx0qn5w7xz67
  0ri611gdilz2c9rsibqhsipbfs9vwcqvs811a52i2bnkhv7w9mgw
2019-10-21 17:47:24 +02:00
..
affinity.cc printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00
affinity.hh Run the daemon worker on the same CPU as the client 2013-08-07 14:02:04 +02:00
archive.cc archive.cc: ignore more posix_fallocate "not supported" error codes 2019-03-01 10:31:17 +08:00
archive.hh Modularize config settings 2018-05-30 13:28:01 +02:00
args.cc nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
args.hh nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
compression.cc Fix build failure if parallel xz is not available 2018-09-17 16:36:11 +02:00
compression.hh Fix Brotli decompression in 'nix log' 2018-08-06 15:40:29 +02:00
config.cc Modularize config settings 2018-05-30 13:28:01 +02:00
config.hh Modularize config settings 2018-05-30 13:28:01 +02:00
finally.hh Add missing #include 2016-11-07 14:35:47 +01:00
hash.cc Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
hash.hh Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
istringstream_nocopy.hh Move istringstream_nocopy to a separate file 2017-03-21 14:43:03 +01:00
json.cc Make std::uncaught_exception warning less noisy 2019-10-09 23:04:11 +02:00
json.hh Make std::uncaught_exception warning less noisy 2019-10-09 23:04:11 +02:00
lazy.hh Figure out the user's home directory if $HOME is not set 2017-05-05 17:08:23 +02:00
local.mk Get BOOST_LDFLAGS from autoconf, fix Ubuntu 16.04 build. 2019-07-03 04:32:25 +02:00
logging.cc Add "warning" verbosity level 2019-06-25 12:44:17 +02:00
logging.hh Add a post-build-hook 2019-08-02 10:48:15 -04:00
lru-cache.hh experimental/optional -> optional 2019-03-14 14:10:52 +01:00
monitor-fd.hh monitor-fds: Fix on macOS. 2018-02-14 18:26:37 -05:00
pool.hh RemoteStore: Close connection if an exception occurs 2018-10-16 23:36:15 +02:00
ref.hh Allow setting the state directory as a store parameter 2016-06-02 16:02:48 +02:00
serialise.cc experimental/optional -> optional 2019-03-14 14:10:52 +01:00
serialise.hh Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
sync.hh sync.hh: return cv_status instead of dropping it, in case useful. 2018-06-18 17:31:00 -05:00
thread-pool.cc Fix a hang in ThreadPool 2017-10-09 15:41:09 +02:00
thread-pool.hh Fix a hang in ThreadPool 2017-10-09 15:41:09 +02:00
types.hh Revert "Fix 'error 9 while decompressing xz file'" 2019-07-10 19:46:15 +02:00
util.cc Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
util.hh Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
xml-writer.cc Fix some random -Wconversion warnings 2018-05-02 13:56:34 +02:00
xml-writer.hh Fix some random -Wconversion warnings 2018-05-02 13:56:34 +02:00