mirror of
https://github.com/nix-community/nixvim.git
synced 2025-09-01 08:16:40 +02:00
modules/nixpkgs: add useGlobalPackages
option
This commit is contained in:
parent
912841c1a7
commit
7790746d38
5 changed files with 185 additions and 18 deletions
83
wrappers/modules/nixpkgs.nix
Normal file
83
wrappers/modules/nixpkgs.nix
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.nixpkgs;
|
||||
opts = options.nixpkgs;
|
||||
argOpts = lib.modules.mergeAttrDefinitionsWithPrio options._module.args;
|
||||
|
||||
normalPrio = lib.modules.defaultOverridePriority;
|
||||
defaultPrio = (lib.mkDefault null).priority;
|
||||
optionDefaultPrio = (lib.mkOptionDefault null).priority;
|
||||
# FIXME: buildPlatform can't use mkOptionDefault because it already defaults to hostPlatform
|
||||
buildPlatformPrio = optionDefaultPrio - 1;
|
||||
|
||||
mkGlobalPackagesAssertion =
|
||||
{
|
||||
assertion,
|
||||
option ? null,
|
||||
loc ? option.loc,
|
||||
issue ? "is overridden",
|
||||
}:
|
||||
{
|
||||
assertion = cfg.useGlobalPackages -> assertion;
|
||||
message =
|
||||
"`${lib.showOption opts.useGlobalPackages.loc}' is enabled, "
|
||||
+ "but `${lib.showOption loc}' ${issue}. "
|
||||
+ lib.optionalString (
|
||||
option != null
|
||||
) "Definition values:${lib.options.showDefs option.definitionsWithLocations}";
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
nixpkgs.useGlobalPackages = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true; # TODO: Added 2025-01-15; switch to false one release after adding a deprecation warning
|
||||
defaultText = lib.literalMD ''`true`, but will change to `false` in a future version.'';
|
||||
description = ''
|
||||
Whether Nixvim should use the ${config.meta.wrapper.name} configuration's `pkgs`,
|
||||
instead of constructing its own instance.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
assertions = map mkGlobalPackagesAssertion [
|
||||
{
|
||||
assertion = opts.pkgs.highestPrio == defaultPrio;
|
||||
option = opts.pkgs;
|
||||
issue = "is overridden";
|
||||
}
|
||||
{
|
||||
assertion = argOpts.pkgs.highestPrio == normalPrio;
|
||||
# FIXME: can't showDefs for an attrOf an option
|
||||
loc = options._module.args.loc ++ [ "pkgs" ];
|
||||
issue = "is overridden";
|
||||
}
|
||||
{
|
||||
assertion = opts.hostPlatform.highestPrio == optionDefaultPrio;
|
||||
option = opts.hostPlatform;
|
||||
issue = "is overridden";
|
||||
}
|
||||
{
|
||||
assertion = opts.buildPlatform.highestPrio == buildPlatformPrio;
|
||||
option = opts.buildPlatform;
|
||||
issue = "is overridden";
|
||||
}
|
||||
{
|
||||
assertion = cfg.config == { };
|
||||
option = opts.config;
|
||||
issue = "is not empty";
|
||||
}
|
||||
{
|
||||
assertion = cfg.overlays == [ ];
|
||||
option = opts.overlays;
|
||||
issue = "is not empty";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
|
@ -11,4 +11,8 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
./nixpkgs.nix
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue