Skip to content

Imply --offline during tab completion#12595

Open
edolstra wants to merge 4 commits intoNixOS:masterfrom
DeterminateSystems:offline-tab-completion
Open

Imply --offline during tab completion#12595
edolstra wants to merge 4 commits intoNixOS:masterfrom
DeterminateSystems:offline-tab-completion

Conversation

@edolstra
Copy link
Member

@edolstra edolstra commented Mar 3, 2025

Motivation

Previously, if you don't have Internet connectivity, tab completion might try to fetch the flake registry, e.g.

$ NIX_GET_COMPLETIONS=4 nix build -vvvvv --offline /home/eelco/De
evaluating file '<nix/derivation-internal.nix>'
downloading 'https://channels.nixos.org/flake-registry.json'...
warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 294 ms
warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 541 ms
warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 1230 ms
warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 2285 ms
warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; using cached version

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Previously, if you don't have Internet connectivity, tab completion
might try to fetch the flake registry, e.g.

  $ NIX_GET_COMPLETIONS=4 nix build -vvvvv --offline /home/eelco/De
  evaluating file '<nix/derivation-internal.nix>'
  downloading 'https://channels.nixos.org/flake-registry.json'...
  warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 294 ms
  warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 541 ms
  warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 1230 ms
  warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; retrying in 2285 ms
  warning: error: unable to download 'https://channels.nixos.org/flake-registry.json': Could not resolve hostname (6) Could not resolve host: channels.nixos.org; using cached version
@github-actions github-actions bot added the new-cli Relating to the "nix" command label Mar 3, 2025
@roberth
Copy link
Member

roberth commented Mar 4, 2025

This doesn't look like a sustainable strategy for dealing with options. We're going to need some serious diagrams to model how all these values come to be, once things get serious (e.g. something like a repeat #11079 but different)

What if instead we

  • put the things we read into settings
  • perform basic processing like extra- as is
  • do any extra processing like this in a getter
  • make more things private so that we don't accidentally bypass the getters

Also cc @Ericson2314

{
// FIXME: should check for command line overrides only.
if (!settings.useSubstitutes.overridden)
settings.useSubstitutes = false;
Copy link
Member

@Mic92 Mic92 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roberth so your idea would be to have useSubstitute, tarballTtl, fileTransfersettings etc check in their getters if we are in offline mode or NIX_COMPLETIONS is set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants