mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 10:58:02 +00:00
flake-parts/setups: refactor NixVim integration
This commit is contained in:
parent
60fe2b8893
commit
64750a7438
@ -4,7 +4,6 @@
|
||||
let
|
||||
cfg = config.setups.home-manager;
|
||||
homeManagerModules = ../../home-manager;
|
||||
partsConfig = config;
|
||||
|
||||
# A thin wrapper around the home-manager configuration function.
|
||||
mkHome =
|
||||
@ -115,21 +114,6 @@ let
|
||||
home.homeDirectory = lib.mkForce setupConfig.homeDirectory;
|
||||
}
|
||||
)
|
||||
|
||||
(lib.mkIf (config.nixvim.instance != null)
|
||||
({ lib, ... }: {
|
||||
imports = [
|
||||
inputs.${config.nixvim.branch}.homeManagerModules.nixvim
|
||||
];
|
||||
|
||||
config.programs.nixvim = { ... }: {
|
||||
enable = lib.mkDefault true;
|
||||
imports =
|
||||
partsConfig.setups.nixvim.configs.${config.nixvim.instance}.modules
|
||||
++ partsConfig.setups.nixvim.sharedModules
|
||||
++ config.nixvim.additionalModules;
|
||||
};
|
||||
}))
|
||||
];
|
||||
|
||||
nixpkgs.config = cfg.sharedNixpkgsConfig;
|
||||
@ -179,7 +163,6 @@ in
|
||||
modules = [
|
||||
(import ./shared/nix-conf.nix { inherit inputs; })
|
||||
./shared/nixpkgs-options.nix
|
||||
./shared/nixvim-instance-options.nix
|
||||
./shared/config-options.nix
|
||||
configType
|
||||
];
|
||||
|
@ -335,22 +335,6 @@ let
|
||||
}
|
||||
))
|
||||
|
||||
# Next, we include the chosen NixVim configuration into NixOS.
|
||||
(lib.mkIf (config.nixvim.instance != null)
|
||||
(
|
||||
{ lib, ... }: {
|
||||
imports = [ inputs.${config.nixvim.branch}.nixosModules.nixvim ];
|
||||
|
||||
programs.nixvim = { ... }: {
|
||||
enable = lib.mkDefault true;
|
||||
imports =
|
||||
partsConfig.setups.nixvim.configs.${config.nixvim.instance}.modules
|
||||
++ partsConfig.setups.nixvim.sharedModules
|
||||
++ setupConfig.nixvim.additionalModules;
|
||||
};
|
||||
}
|
||||
))
|
||||
|
||||
# Then we include the Disko configuration (if there's any).
|
||||
(lib.mkIf (config.diskoConfigs != [ ]) (
|
||||
let
|
||||
@ -413,7 +397,6 @@ in
|
||||
modules = [
|
||||
(import ./shared/nix-conf.nix { inherit inputs; })
|
||||
./shared/config-options.nix
|
||||
./shared/nixvim-instance-options.nix
|
||||
./shared/home-manager-users.nix
|
||||
./shared/nixpkgs-options.nix
|
||||
configType
|
||||
|
@ -7,6 +7,7 @@
|
||||
}:
|
||||
|
||||
let
|
||||
partsConfig = config;
|
||||
cfg = config.setups.nixvim;
|
||||
nixvimModules = ../../nixvim;
|
||||
|
||||
@ -106,6 +107,59 @@ let
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nixvimIntegrationModule = { name, config, lib, ... }: {
|
||||
options.nixvim = {
|
||||
instance = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = null;
|
||||
example = "fiesta";
|
||||
description = ''
|
||||
The name of the NixVim configuration from
|
||||
{option}`setups.nixvim.configs.<name>` to be included as part
|
||||
of the wider-scoped environment.
|
||||
'';
|
||||
};
|
||||
|
||||
branch = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "nixvim";
|
||||
example = "nixvim-stable";
|
||||
description = ''
|
||||
The branch of NixVim to be used for the module.
|
||||
|
||||
::: {.tip}
|
||||
A rule of thumb for properly setting up NixVim with the wider-scoped
|
||||
environment is it should match the nixpkgs version of it. For example,
|
||||
a NixOS system of `nixos-23.11` nixpkgs branch should be paired with a NixVim
|
||||
branch of `nixos-23.11`.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
additionalModules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of additional NixVim modules to be included.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.nixvim.instance != null) {
|
||||
modules = [
|
||||
({ lib, ... }: {
|
||||
programs.nixvim = { ... }: {
|
||||
enable = lib.mkDefault true;
|
||||
imports =
|
||||
partsConfig.setups.nixvim.configs.${config.nixvim.instance}.modules
|
||||
++ partsConfig.setups.nixvim.sharedModules
|
||||
++ config.nixvim.additionalModules;
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.setups.nixvim = {
|
||||
@ -141,6 +195,28 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
options.setups.nixos.configs = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule [
|
||||
nixvimIntegrationModule
|
||||
({ config, lib, ... }: {
|
||||
config.modules = [
|
||||
inputs.${config.nixvim.branch}.nixosModules.nixvim
|
||||
];
|
||||
})
|
||||
]);
|
||||
};
|
||||
|
||||
options.setups.home-manager.configs = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule [
|
||||
nixvimIntegrationModule
|
||||
({ config, lib, ... }: {
|
||||
config.modules = [
|
||||
inputs.${config.nixvim.branch}.homeManagerModules.nixvim
|
||||
];
|
||||
})
|
||||
]);
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.configs != { }) {
|
||||
setups.nixvim.sharedNixpkgsConfig = config.setups.sharedNixpkgsConfig;
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
{ lib, ... }: {
|
||||
options.nixvim = {
|
||||
instance = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = null;
|
||||
example = "fiesta";
|
||||
description = ''
|
||||
The name of the NixVim configuration from
|
||||
{option}`setups.nixvim.configs.<name>` to be included as part
|
||||
of the wider-scoped environment.
|
||||
'';
|
||||
};
|
||||
|
||||
branch = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "nixvim";
|
||||
example = "nixvim-stable";
|
||||
description = ''
|
||||
The branch of NixVim to be used for the module.
|
||||
|
||||
::: {.tip}
|
||||
A rule of thumb for properly setting up NixVim with the wider-scoped
|
||||
environment is it should match the nixpkgs version of it. For example,
|
||||
a NixOS system of `nixos-23.11` nixpkgs branch should be paired with a NixVim
|
||||
branch of `nixos-23.11`.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
additionalModules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of additional NixVim modules to be included.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user