mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-12 06:19:00 +00:00
flake-parts/setups: refactor and add NixVim instance for home-manager configs
This commit is contained in:
parent
f5e9d12bb6
commit
ed1264c062
@ -4,6 +4,7 @@
|
||||
let
|
||||
cfg = config.setups.home-manager;
|
||||
homeManagerModules = ../../home-manager;
|
||||
partsConfig = config;
|
||||
|
||||
# A thin wrapper around the home-manager configuration function.
|
||||
mkHome = { system, nixpkgsBranch ? "nixpkgs", homeManagerBranch ? "home-manager", extraModules ? [ ] }:
|
||||
@ -22,19 +23,9 @@ let
|
||||
|
||||
deploySettingsType = { config, lib, username, ... }: {
|
||||
freeformType = with lib.types; attrsOf anything;
|
||||
imports = [ ./shared/deploy-node-type.nix ];
|
||||
|
||||
options = {
|
||||
fastConnection =
|
||||
lib.mkEnableOption "deploy-rs to assume the target machine is considered fast";
|
||||
autoRollback =
|
||||
lib.mkEnableOption "deploy-rs auto-rollback feature" // {
|
||||
default = true;
|
||||
};
|
||||
magicRollback =
|
||||
lib.mkEnableOption "deploy-rs magic rollback feature" // {
|
||||
default = true;
|
||||
};
|
||||
remoteBuild = lib.mkEnableOption "pass the build process to the remote machine";
|
||||
profiles = lib.mkOption {
|
||||
type = with lib.types; functionTo (attrsOf anything);
|
||||
default = homeenv: {
|
||||
@ -71,31 +62,8 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
configType =
|
||||
let
|
||||
partsConfig = config;
|
||||
in
|
||||
{ config, name, lib, ... }: {
|
||||
configType = { config, name, lib, ... }: {
|
||||
options = {
|
||||
systems = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = partsConfig.systems;
|
||||
defaultText = "config.systems";
|
||||
example = [ "x86_64-linux" "aarch64-linux" ];
|
||||
description = ''
|
||||
A list of platforms that the NixOS configuration is supposed to be
|
||||
deployed on.
|
||||
'';
|
||||
};
|
||||
|
||||
modules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of NixOS modules specific for that host.
|
||||
'';
|
||||
};
|
||||
|
||||
overlays = lib.mkOption {
|
||||
type = with lib.types; listOf (functionTo raw);
|
||||
default = [ ];
|
||||
@ -174,6 +142,17 @@ let
|
||||
home.homeDirectory = lib.mkForce setupConfig.homeDirectory;
|
||||
}
|
||||
)
|
||||
|
||||
(lib.mkIf (config.nixvim.instance != null)
|
||||
({ lib, ... }: {
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
imports =
|
||||
partsConfig.setups.nixvim.configs.${config.nixvim.instance}.modules
|
||||
++ partsConfig.setups.nixvim.sharedModules
|
||||
++ config.nixvim.additionalModules;
|
||||
};
|
||||
}))
|
||||
];
|
||||
};
|
||||
};
|
||||
@ -209,7 +188,14 @@ in
|
||||
};
|
||||
|
||||
configs = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule configType);
|
||||
type = with lib.types; attrsOf (submoduleWith {
|
||||
specialArgs = { inherit (config) systems; };
|
||||
modules = [
|
||||
./shared/nixvim-instance-options.nix
|
||||
./shared/config-options.nix
|
||||
configType
|
||||
];
|
||||
});
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set of metadata for the declarative home-manager setups.
|
||||
|
@ -54,19 +54,9 @@ let
|
||||
|
||||
deployNodeType = { config, lib, ... }: {
|
||||
freeformType = with lib.types; attrsOf anything;
|
||||
imports = [ ./shared/deploy-node-type.nix ];
|
||||
|
||||
options = {
|
||||
fastConnection =
|
||||
lib.mkEnableOption "deploy-rs to assume the target machine is considered fast";
|
||||
autoRollback =
|
||||
lib.mkEnableOption "deploy-rs auto-rollback feature" // {
|
||||
default = true;
|
||||
};
|
||||
magicRollback =
|
||||
lib.mkEnableOption "deploy-rs magic rollback feature" // {
|
||||
default = true;
|
||||
};
|
||||
remoteBuild = lib.mkEnableOption "pass the build process to the remote machine";
|
||||
profiles = lib.mkOption {
|
||||
type = with lib.types; functionTo (attrsOf anything);
|
||||
default = os: {
|
||||
@ -144,17 +134,6 @@ let
|
||||
|
||||
configType = { config, name, lib, ... }: {
|
||||
options = {
|
||||
systems = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = partsConfig.systems;
|
||||
defaultText = "config.systems";
|
||||
example = [ "x86_64-linux" "aarch64-linux" ];
|
||||
description = ''
|
||||
A list of platforms that the NixOS configuration is supposed to be
|
||||
deployed on.
|
||||
'';
|
||||
};
|
||||
|
||||
formats = lib.mkOption {
|
||||
type = with lib.types; nullOr (listOf str);
|
||||
default = [ "iso" ];
|
||||
@ -166,14 +145,6 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
modules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of NixOS modules specific for that host.
|
||||
'';
|
||||
};
|
||||
|
||||
overlays = lib.mkOption {
|
||||
type = with lib.types; listOf (functionTo raw);
|
||||
default = [ ];
|
||||
@ -305,37 +276,6 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
nixvim = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
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 NixOS system.
|
||||
'';
|
||||
};
|
||||
|
||||
additionalModules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of additional NixVim modules to be included.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
description = ''
|
||||
An optional NixVim inclusion for the NixOS system. Take note, this
|
||||
will override whatever Neovim configuration from your NixOS system so
|
||||
be sure to only use this if you have none.
|
||||
'';
|
||||
};
|
||||
|
||||
deploy = lib.mkOption {
|
||||
type = with lib.types; nullOr (submodule deployNodeType);
|
||||
default = null;
|
||||
@ -499,7 +439,14 @@ in
|
||||
};
|
||||
|
||||
configs = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule configType);
|
||||
type = with lib.types; attrsOf (submoduleWith {
|
||||
specialArgs = { inherit (config) systems; };
|
||||
modules = [
|
||||
./shared/config-options.nix
|
||||
./shared/nixvim-instance-options.nix
|
||||
configType
|
||||
];
|
||||
});
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set of metadata for the declarative NixOS setups. This
|
||||
|
@ -41,16 +41,6 @@ let
|
||||
|
||||
configType = { name, lib, config, ... }: {
|
||||
options = {
|
||||
systems = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = partsConfig.systems;
|
||||
defaultText = "config.systems";
|
||||
example = [ "x86_64-linux" "aarch64-linux" ];
|
||||
description = ''
|
||||
A list of systems the NixVim configuration will be built against.
|
||||
'';
|
||||
};
|
||||
|
||||
nixpkgsBranches = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
description = ''
|
||||
@ -62,14 +52,6 @@ let
|
||||
"nixos-stable"
|
||||
];
|
||||
};
|
||||
|
||||
modules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [];
|
||||
description = ''
|
||||
Additional NixVim modules to use.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
@ -82,7 +64,13 @@ in
|
||||
{
|
||||
options.setups.nixvim = {
|
||||
configs = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule configType);
|
||||
type = with lib.types; attrsOf (submoduleWith {
|
||||
specialArgs = { inherit (config) systems; };
|
||||
modules = [
|
||||
./shared/config-options.nix
|
||||
configType
|
||||
];
|
||||
});
|
||||
default = {};
|
||||
description = ''
|
||||
A set of NixVim configurations to be integrated into the declarative
|
||||
|
22
modules/flake-parts/setups/shared/config-options.nix
Normal file
22
modules/flake-parts/setups/shared/config-options.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ lib, systems, ... }: {
|
||||
options = {
|
||||
systems = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = systems;
|
||||
defaultText = "config.systems";
|
||||
example = [ "x86_64-linux" "aarch64-linux" ];
|
||||
description = ''
|
||||
A list of platforms that the NixOS configuration is supposed to be
|
||||
deployed on.
|
||||
'';
|
||||
};
|
||||
|
||||
modules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of NixOS modules specific for that host.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
15
modules/flake-parts/setups/shared/deploy-node-type.nix
Normal file
15
modules/flake-parts/setups/shared/deploy-node-type.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{ lib, ... }: {
|
||||
options = {
|
||||
fastConnection =
|
||||
lib.mkEnableOption "deploy-rs to assume the target machine is considered fast";
|
||||
autoRollback =
|
||||
lib.mkEnableOption "deploy-rs auto-rollback feature" // {
|
||||
default = true;
|
||||
};
|
||||
magicRollback =
|
||||
lib.mkEnableOption "deploy-rs magic rollback feature" // {
|
||||
default = true;
|
||||
};
|
||||
remoteBuild = lib.mkEnableOption "pass the build process to the remote machine";
|
||||
};
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
{ lib, ... }: {
|
||||
options.nixvim = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
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 NixOS system.
|
||||
'';
|
||||
};
|
||||
|
||||
additionalModules = lib.mkOption {
|
||||
type = with lib.types; listOf raw;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of additional NixVim modules to be included.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
description = ''
|
||||
An optional NixVim inclusion for the environment. Take note, this
|
||||
will override whatever Neovim configuration from your environment so
|
||||
be sure to only use this if you have none.
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user