Skip to content

Commit

Permalink
modules/nixpkgs: init useGlobalPackages option
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Dec 17, 2024
1 parent 99f66f1 commit 87176c7
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions wrappers/_shared.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,45 @@ let
setAttrByPath
;
cfg = config.programs.nixvim;

# TODO: Find a way to document the options declared here
nixpkgsModule =
{ config, ... }:
{
_file = ./_shared.nix;

options.nixpkgs = {
useGlobalPackages = lib.mkOption {
type = lib.types.bool;
default = true; # TODO: Added 2024-10-20; switch to false one release after adding a deprecation warning
description = ''
Whether Nixvim should use the host configuration's `pkgs` instance.
The host configuration is usually home-manager, nixos, or nix-darwin.
When false, an instance of nixpkgs will be constructed by nixvim.
'';
};
};

config = {
nixpkgs = {
# Use global packages by default in nixvim's submodule
pkgs = lib.mkIf config.nixpkgs.useGlobalPackages (lib.mkForce pkgs);

# Inherit platform spec
# FIXME: buildPlatform can't use option-default because it already has a default
# (it defaults to hostPlatform)...
hostPlatform = lib.mkOptionDefault pkgs.stdenv.hostPlatform;
buildPlatform = lib.mkDefault pkgs.stdenv.buildPlatform;
};
};
};
nixvimConfiguration = config.lib.nixvim.modules.evalNixvim (
evalArgs
// {
modules = evalArgs.modules or [ ] ++ [
{
_file = ./_shared.nix;

nixpkgs = {
# Use global packages by default in nixvim's submodule
# TODO: `useGlobalPackages` option and/or deprecate using host packages?
pkgs = lib.mkDefault pkgs;

# Inherit platform spec
# FIXME: buildPlatform can't use option-default because it already has a default
# (it defaults to hostPlatform)...
hostPlatform = lib.mkOptionDefault pkgs.stdenv.hostPlatform;
buildPlatform = lib.mkDefault pkgs.stdenv.buildPlatform;
};
}
nixpkgsModule
];
}
);
Expand Down

0 comments on commit 87176c7

Please sign in to comment.