nix-super/src/nix
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
..
add-to-store.cc experimental/optional -> optional 2019-03-14 14:10:52 +01:00
build.cc Merge branch 'fix/dry-run-partially' of https://github.com/dtzWill/nix 2018-02-22 12:18:20 +01:00
cat.cc Replace Unicode quotes in user-facing strings by ASCII 2017-07-30 12:32:45 +01:00
command.cc Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
command.hh Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
copy.cc nix copy: Rename --substitute to --substitute-on-destination 2019-07-10 11:28:37 +02:00
doctor.cc nix doctor: return nonzero exitcode if a check fails 2018-10-29 12:09:22 +00:00
dump-path.cc Fix #1762 2018-02-13 14:26:19 +00:00
edit.cc Don't catch exceptions by value 2019-09-22 21:56:56 +02:00
eval.cc nix eval: Stop progress bar before printing the result 2018-01-17 12:04:44 +01:00
hash.cc Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
installables.cc SourceExprCommand::getSourceExpr(): Allocate more space 2019-10-21 13:14:39 +02:00
legacy.cc Start of new Nix command-line interface 2016-02-09 21:28:29 +01:00
legacy.hh Fix Darwin build 2016-03-15 12:11:27 +01:00
local.mk Get BOOST_LDFLAGS from autoconf, fix Ubuntu 16.04 build. 2019-07-03 04:32:25 +02:00
log.cc nix log: use pager 2018-01-12 15:05:26 -06:00
ls.cc nix ls-nar: allow reading from FIFOs 2018-11-16 16:24:36 +01:00
main.cc Add experimental-features setting 2019-10-21 13:34:44 +02:00
make-content-addressable.cc Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
optimise-store.cc nix optimise-store: Add 2017-08-16 20:56:03 +02:00
path-info.cc nix path-info: Remove trailing spaces 2018-09-01 00:04:57 +02:00
ping-store.cc Manual: Update chapter on remote builds 2018-02-21 16:24:26 +01:00
progress-bar.cc Filter ANSI escape sequences in -L output 2019-10-09 23:25:06 +02:00
progress-bar.hh nix: Add --print-build-logs flag 2019-05-15 17:33:56 +02:00
repl.cc Fix C++ compatibility with older editline versions. 2019-07-03 04:32:25 +02:00
run.cc Disable CLONE_NEWUSER when it’s unavailable 2019-07-25 14:42:25 -04:00
search.cc nix search: Don't quietly ignore errors 2019-10-09 14:46:58 +02:00
show-config.cc Modularize config settings 2018-05-30 13:28:01 +02:00
show-derivation.cc Add "nix show-derivation" 2017-09-25 13:43:35 +02:00
sigs.cc nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
upgrade-nix.cc nix upgrade-nix: Handle .nix-profile being a link to .../profiles/per-user/... 2018-08-30 21:18:56 +02:00
verify.cc Allow content-addressable paths to have references 2019-10-21 17:47:24 +02:00
why-depends.cc nix why-depends: render output into $PAGER 2018-07-03 12:49:12 +02:00