Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a use-registries config option (and deprecate --no-registries ) #4976

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

balsoft
Copy link
Member

@balsoft balsoft commented Jul 2, 2021

Some people want to avoid using registries at all on their system; Instead
of having to add --no-registries to every command, this commit allows to
set registries = false in the config. --no-registries is still allowed
everywhere it was allowed previously, but now as a shorthand to --option
registries false rather than a separate flag.

@thufschmitt
Copy link
Member

Some people want to avoid using registries at all on their system

Isn’t it simpler to just set flake-registry to an empty registry in that case? (possibly making the empty file or empty json object a valid registry to make this even simpler)

@balsoft
Copy link
Member Author

balsoft commented Jul 2, 2021

Isn’t it simpler to just set flake-registry to an empty registry in that case?

That was my first thought as well, but emptying flake-registry still leaves a system registry (/etc/nix/registry.json) and a user registry ($XDG_CONFIG_HOME/nix/registry.json). This option disables registries completely.

@nrdxp
Copy link

nrdxp commented Jul 2, 2021

Until this is merged, it is also possible to simply specify an empty registry, to simulate no registry:

# registry.json
{
  "version": 2
}

But I agree that a config option is better.

@balsoft
Copy link
Member Author

balsoft commented Jul 2, 2021

Until this is merged, it is also possible to simply specify an empty registry, to simulate no registry:

Once again, this doesn't quite work since there are also user and system registries.

src/libstore/globals.hh Outdated Show resolved Hide resolved
@@ -102,7 +102,7 @@ struct LockFlags

/* Whether to use the registries to lookup indirect flake
references like 'nixpkgs'. */
bool useRegistries = true;
std::optional<bool> useRegistries = std::nullopt;
Copy link
Member

Choose a reason for hiding this comment

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

A tristate is confusing to me, maybe it should just be initialized to settings.registries?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have thought about this a bit, I don't like initializing fields with global state. It may be confusing if the state changes after the structure has been initialized, since then lockFlags.useRegistries may go out of sync with settings.useRegistries.

src/libexpr/flake/flake.cc Outdated Show resolved Hide resolved
@balsoft balsoft force-pushed the balsoft/no-registries branch from 859e612 to 82148d7 Compare July 16, 2021 20:23
@balsoft balsoft requested a review from edolstra July 16, 2021 20:24
@balsoft balsoft changed the title Make registries a config option (and remove --no-registries flag) Make use-registries a config option (and deprecate --no-registries) Jul 16, 2021
Some people want to avoid using registries at all on their system; Instead
of having to add --no-registries to every command, this commit allows to
set use-registries = false in the config. --no-registries is still allowed
everywhere it was allowed previously, but is now deprecated.

Co-authored-by: Eelco Dolstra <[email protected]>
@balsoft balsoft force-pushed the balsoft/no-registries branch from 82148d7 to 3e57e34 Compare July 16, 2021 20:26
@balsoft balsoft changed the title Make use-registries a config option (and deprecate --no-registries) Add a use-registries config option (and deprecate --no-registries) Jul 16, 2021
@balsoft balsoft changed the title Add a use-registries config option (and deprecate --no-registries) Add a use-registries config option (and deprecate --no-registries ) Jul 16, 2021
@edolstra edolstra merged commit fc248cf into NixOS:master Jul 21, 2021
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.

4 participants