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

modules/nixpkgs: complete the MVP #2738

Merged
merged 8 commits into from
Jan 17, 2025

Conversation

MattSturgeon
Copy link
Member

@MattSturgeon MattSturgeon commented Dec 23, 2024

This PR finally gets the nixpkgs module to a fully functional state. If nixpkgs.pkgs is not defined, then an instance of nixpkgs is constructed from nixpkgs.source.

Constructing nixpkgs also requires knowing which system to target, so the hostPlatform and buildPlatform options are included.

I also included the nixpkgs.config option. This could just be attrsOf anything, but I've used the upstream option-type because it handles some special cases while merging definitions.

I've also added the non-standalone option nixpkgs.useGlobalPackages, which automatically sets nixpkgs.pkgs to the "host" or "global" packages; i.e. the pkgs arg in use by the outer module eval.

Most implementation is directly based on https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/nixpkgs.nix

Follow up to:

Closes #2022
Closes #2437
Fixes #1784

Future work

system agnostic Nixvim factory

Constructing pkgs within the module system allows us to have a system-agnostic replacement for makeNixvimWithModule and somewhat simplify the standalone template

Note: lib.nixvim.modules.evalNixvim is already system-agnostic. We simply need to provide documentation and/or new wrapper-functions for use by end-users.

Migrating useGlobalPackages default

I'm not 100% sure I know a good way to warn about that planned transition though. Maybe we'll just have to have an obnoxious but temporary warning shown to all users? Could still be missed by users who don't update very often.

@MattSturgeon MattSturgeon marked this pull request as ready for review December 23, 2024 16:19
@MattSturgeon MattSturgeon requested a review from a team December 23, 2024 16:39
@MattSturgeon MattSturgeon force-pushed the nixpkgs_complete branch 4 times, most recently from e32c022 to 737ff93 Compare December 23, 2024 17:16
@MattSturgeon MattSturgeon requested a review from a team December 23, 2024 17:37
lib/modules.nix Outdated Show resolved Hide resolved
lib/tests.nix Show resolved Hide resolved
lib/tests.nix Show resolved Hide resolved
wrappers/_shared.nix Outdated Show resolved Hide resolved
modules/top-level/nixpkgs.nix Show resolved Hide resolved
tests/main.nix Outdated Show resolved Hide resolved
tests/test-sources/modules/nixpkgs.nix Outdated Show resolved Hide resolved
wrappers/modules/shared.nix Outdated Show resolved Hide resolved
modules/top-level/nixpkgs.nix Show resolved Hide resolved
tests/nixpkgs-module.nix Show resolved Hide resolved
@khaneliman

This comment has been minimized.

@MattSturgeon
Copy link
Member Author

Thanks for the help @khaneliman

I've reduced flakyness by testing with a mock nixpkgs source rather than downloading a real instance.

I've also narrowed the scope of the tests to focus on only the nixpkgs module and its dependencies. That way we aren't accidentally using the pkgs instance elsewhere in unrelated modules.

The testWrappers tests still test against a full nixvim configuration with all modules, due to them using the actual wrapper modules.

@MattSturgeon MattSturgeon force-pushed the nixpkgs_complete branch 2 times, most recently from 6d4afd5 to 79d66da Compare January 16, 2025 23:45
Copy link
Member

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

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

As far as I'm able to understand those changes (~70%), this looks good !
I trust you and @traxys on the details ;)

@MattSturgeon MattSturgeon force-pushed the nixpkgs_complete branch 3 times, most recently from 331f94a to 0104e26 Compare January 17, 2025 09:59
@MattSturgeon
Copy link
Member Author

@mergify queue

Copy link
Contributor

mergify bot commented Jan 17, 2025

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 5147429

Copy link
Contributor

mergify bot commented Jan 17, 2025

This pull request, with head sha 51474292cd0c5ace056a0b26df6c38e997338399, has been successfully merged with fast-forward by Mergify.

This pull request will be automatically closed by GitHub.

As soon as GitHub detects that the sha 51474292cd0c5ace056a0b26df6c38e997338399 is part of the main branch, it will mark this pull request as merged.

It is possible for this pull request to remain open if this detection does not happen, this usually happens when a force-push is done on this branch nixpkgs_complete, this means GitHub will fail to detect the merge.

@mergify mergify bot merged commit 5147429 into nix-community:main Jan 17, 2025
4 checks passed
@mergify mergify bot temporarily deployed to github-pages January 17, 2025 10:20 Inactive
@MattSturgeon MattSturgeon deleted the nixpkgs_complete branch January 17, 2025 10:25
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.

modules/misc: nixpkgs module
4 participants