Skip to content

Conversation

edolstra
Copy link
Member

This makes nix build flake:... etc. register the downloaded flake source trees as a GC root to ensure that they won't be garbage collected, which would be bad if you're offline. Also, fetchGit now works offline; if it can't fetch the latest version, it just continues with the most recently fetched version.

TODO: add some commands for manually adding / releasing GC roots? (E.g. nix flake keep nixpkgs.)

Fixes #2868.

edolstra added 3 commits May 23, 2019 23:38
Instead print a warning that we're continuing with the most recently
fetched version.
This ensures that flakes don't get garbage-collected, which is
important to get nix-channel-like behaviour.

For example, running

  $ nix build hydra:

will create a GC root

  ~/.cache/nix/flake-closures/hydra -> /nix/store/xarfiqcwa4w8r4qpz1a769xxs8c3phgn-flake-closure

where the contents/references of the linked file in the store are the
flake source trees used by the 'hydra' flake:

  /nix/store/n6d5f5lkpfjbmkyby0nlg8y1wbkmbc7i-source
  /nix/store/vbkg4zy1qd29fnhflsv9k2j9jnbqd5m2-source
  /nix/store/z46xni7d47s5wk694359mq9ay353ar94-source

Note that this in itself is not enough to allow offline use; the
fetcher for the flakeref (e.g. fetchGit or downloadCached) must not
fail if it cannot fetch the latest version of the file, so long as it
knows a cached version.

Issue #2868.
@edolstra edolstra requested review from grahamc and CSVdB May 23, 2019 21:58
@edolstra edolstra merged commit 981f686 into flakes May 25, 2019
@edolstra edolstra deleted the offline-flakes branch May 29, 2019 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant