-
-
Notifications
You must be signed in to change notification settings - Fork 330
modules/nixpkgs: initial pkgs
option; drop defaultPkgs
specialArg
#2301
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
Merged
MattSturgeon
merged 3 commits into
nix-community:main
from
MattSturgeon:nixpkgs_module_minimal
Sep 27, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
./assertions.nix | ||
./context.nix | ||
./meta.nix | ||
./nixpkgs.nix | ||
./nixvim-info.nix | ||
]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
imports = [ | ||
../. | ||
./files | ||
./nixpkgs.nix | ||
./output.nix | ||
./readonly-renames.nix | ||
./test.nix | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
config, | ||
options, | ||
lib, | ||
... | ||
}: | ||
let | ||
cfg = config.nixpkgs; | ||
opt = options.nixpkgs; | ||
in | ||
{ | ||
options.nixpkgs = { | ||
pkgs = lib.mkOption { | ||
# TODO: | ||
# defaultText = lib.literalExpression '' | ||
# import "''${nixos}/.." { | ||
# inherit (cfg) config overlays localSystem crossSystem; | ||
# } | ||
# ''; | ||
MattSturgeon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defaultText = lib.literalMD '' | ||
The `pkgs` inherited from your host config (i.e. NixOS, home-manager, or nix-darwin), | ||
or the `pkgs` supplied to `makeNixvimWithModule` when building a standalone nixvim. | ||
|
||
> [!CAUTION] | ||
> This default will be removed in a future version of nixvim | ||
''; | ||
type = lib.types.pkgs // { | ||
description = "An evaluation of Nixpkgs; the top level attribute set of packages"; | ||
}; | ||
example = lib.literalExpression "import <nixpkgs> { }"; | ||
description = '' | ||
If set, the `pkgs` argument to all Nixvim modules is the value of this option. | ||
|
||
<!-- TODO: remove --> | ||
MattSturgeon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
If unset, an assertion will trigger. In the future a `pkgs` instance will be constructed. | ||
|
||
<!-- | ||
TODO: | ||
If unset, the pkgs argument is determined as shown in the default value for this option. | ||
|
||
TODO: | ||
The default value imports the Nixpkgs input specified in Nixvim's `flake.lock`. | ||
The `config`, `overlays`, `localSystem`, and `crossSystem` come from this option's siblings. | ||
--> | ||
|
||
This option can be used by external applications to increase the performance of evaluation, | ||
or to create packages that depend on a container that should be built with the exact same | ||
evaluation of Nixpkgs, for example. | ||
Applications like this should set their default value using `lib.mkDefault`, | ||
so user-provided configuration can override it without using `lib`. | ||
E.g. Nixvim's home-manager module can re-use the `pkgs` instance from the "host" modules. | ||
|
||
> [!NOTE] | ||
> Using a distinct version of Nixpkgs with Nixvim may be an unexpected source of problems. | ||
> Use this option with care. | ||
''; | ||
}; | ||
}; | ||
|
||
config = { | ||
# For now we only set this when `nixpkgs.pkgs` is defined | ||
# TODO: construct a default pkgs instance from pkgsPath and cfg options | ||
# https://github.com/nix-community/nixvim/issues/1784 | ||
_module.args = lib.optionalAttrs opt.pkgs.isDefined { | ||
# We explicitly set the default override priority, so that we do not need | ||
# to evaluate finalPkgs in case an override is placed on `_module.args.pkgs`. | ||
# After all, to determine a definition priority, we need to evaluate `._type`, | ||
# which is somewhat costly for Nixpkgs. With an explicit priority, we only | ||
# evaluate the wrapper to find out that the priority is lower, and then we | ||
# don't need to evaluate `finalPkgs`. | ||
pkgs = lib.mkOverride lib.modules.defaultOverridePriority cfg.pkgs.__splicedPackages; | ||
}; | ||
|
||
assertions = [ | ||
{ | ||
# TODO: Remove or rephrase once pkgs can be constructed internally | ||
assertion = config._module.args ? pkgs; | ||
message = '' | ||
`nixpkgs.pkgs` is not defined. In the future, this option will be optional. | ||
Currently a pkgs instance must be evaluated externally and assigned to `nixpkgs.pkgs` option. | ||
''; | ||
} | ||
]; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.