mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 12:19:07 +00:00
flake-parts/setups/nixvim: merge into a unified list of components
At least, it made the module code and configuration easier with `nixpkgs.lib.cartesianProductOfSets`.
This commit is contained in:
parent
17c36bf29c
commit
2dd2175250
@ -1,25 +1,30 @@
|
|||||||
{ inputs, ... }:
|
{ inputs, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
setups.nixvim.configs = {
|
setups.nixvim.configs = {
|
||||||
fiesta = {
|
fiesta = {
|
||||||
nixpkgsBranches = [
|
components = [
|
||||||
"nixos-unstable"
|
{
|
||||||
];
|
nixpkgsBranch = "nixos-unstable";
|
||||||
nixvimBranch = "nixvim-unstable";
|
nixvimBranch = "nixvim-unstable";
|
||||||
neovimPackages = p: with p; [
|
neovimPackage = pkgs: pkgs.neovim;
|
||||||
neovim
|
overlays = [
|
||||||
|
inputs.neovim-nightly-overlay.overlays.default
|
||||||
|
];
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
trovebelt = {
|
trovebelt = {
|
||||||
nixpkgsBranches = [
|
components = lib.cartesianProductOfSets {
|
||||||
"nixos-unstable"
|
nixpkgsBranch = [ "nixos-unstable" ];
|
||||||
];
|
nixvimBranch = [ "nixvim-unstable" ];
|
||||||
nixvimBranch = "nixos-unstable";
|
neovimPackage = [ (pkgs: pkgs.neovim) ];
|
||||||
neovimPackages = p: with p; [
|
overlays = [
|
||||||
neovim
|
[ inputs.neovim-nightly-overlay.overlays.default ]
|
||||||
];
|
[ ]
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
, lib
|
, lib
|
||||||
, config
|
, config
|
||||||
|
|
||||||
, defaultOverlays
|
|
||||||
|
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -33,18 +31,22 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
configType = { name, lib, config, ... }: {
|
componentType = { lib, config, ... }: {
|
||||||
options = {
|
options = {
|
||||||
nixpkgsBranches = lib.mkOption {
|
nixpkgsBranch = lib.mkOption {
|
||||||
type = with lib.types; listOf str;
|
type = lib.types.nonEmptyStr;
|
||||||
|
default = "nixpkgs";
|
||||||
|
example = "nixos-unstable";
|
||||||
description = ''
|
description = ''
|
||||||
A list of nixpkgs branches for the NixVim configuration to be built
|
The nixpkgs branch for the NixVim configuration to be built
|
||||||
against.
|
against.
|
||||||
|
|
||||||
|
::: {.note}
|
||||||
|
This refers to your flake inputs so in order to support multiple
|
||||||
|
nixpkgs branches, you need to import multiple nixpkgs as part of the
|
||||||
|
`inputs` flake attribute.
|
||||||
|
:::
|
||||||
'';
|
'';
|
||||||
example = [
|
|
||||||
"nixos-unstable"
|
|
||||||
"nixos-stable"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nixvimBranch = lib.mkOption {
|
nixvimBranch = lib.mkOption {
|
||||||
@ -52,28 +54,64 @@ let
|
|||||||
default = "nixvim";
|
default = "nixvim";
|
||||||
example = "nixvim-unstable";
|
example = "nixvim-unstable";
|
||||||
description = ''
|
description = ''
|
||||||
The NixVim branch to be used for the configuration.
|
The NixVim branch to be used for the NixVim configuration.
|
||||||
|
|
||||||
|
It is recommend to match the NixVim branch with the nixpkgs branch.
|
||||||
|
For example, a NixVim configuration of `nixos-24.05` should be paired
|
||||||
|
with nixpkgs `nixos-24.05` branch.
|
||||||
|
|
||||||
|
::: {.note}
|
||||||
|
This refers to your flake inputs so in order to support multiple
|
||||||
|
NixVim branches, you need to import multiple NixVim branches as part
|
||||||
|
of the `inputs` flake attribute.
|
||||||
|
:::
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
neovimPackages = lib.mkOption {
|
neovimPackage = lib.mkOption {
|
||||||
type = with lib.types; functionTo (listOf package);
|
type = with lib.types; functionTo package;
|
||||||
default = pkgs: with pkgs; [ neovim ];
|
default = pkgs: pkgs.neovim;
|
||||||
defaultText = "pkgs: with pkgs; [ neovim ]";
|
defaultText = "pkgs: pkgs.neovim";
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
pkgs: with pkgs; [
|
pkgs: pkgs.neovim-nightly
|
||||||
(wrapNeovim neovim-unwrapped { })
|
'';
|
||||||
neovim-nightly
|
description = ''
|
||||||
|
The package to be used for the NixVim configuration. Since this is
|
||||||
|
used per-system, it has to be a function returning a package from the
|
||||||
|
given nixpkgs instance.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
overlays = lib.mkOption {
|
||||||
|
type = with lib.types; listOf (functionTo raw);
|
||||||
|
default = [ ];
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
[
|
||||||
|
inputs.neovim-nightly-overlay.overlays.default
|
||||||
]
|
]
|
||||||
'';
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
A list of Neovim packages from different branches to be built
|
A list of overlays to be applied for the nixpkgs instance.
|
||||||
against. Since this is to be used per-system, it should be a function
|
|
||||||
that returns a list of packages where the given statement is the
|
|
||||||
nixpkgs instance.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
configType = { name, lib, config, ... }: {
|
||||||
|
options = {
|
||||||
|
components = lib.mkOption {
|
||||||
|
type = with lib.types; listOf (submodule componentType);
|
||||||
|
description = ''
|
||||||
|
A list of specific components for the NixVim configuration to be
|
||||||
|
built against.
|
||||||
|
'';
|
||||||
|
example = [
|
||||||
|
{ nixpkgsBranch = "nixos-unstable"; nixvimBranch = "nixvim-unstable"; }
|
||||||
|
{ nixpkgsBranch = "nixos-stable"; nixvimBranch = "nixvim-stable"; }
|
||||||
|
{ nixpkgsBranch = "nixos-stable"; nixvimBranch = "nixvim-stable"; neovimPackage = pkgs: pkgs.neovim-nightly; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
modules = [
|
modules = [
|
||||||
@ -129,38 +167,26 @@ in
|
|||||||
let
|
let
|
||||||
generateNixvimConfigs = name: metadata:
|
generateNixvimConfigs = name: metadata:
|
||||||
let
|
let
|
||||||
iterateThruBranches = nixpkgsBranch:
|
mkNixvimConfig' = component:
|
||||||
let
|
let
|
||||||
pkgs = import inputs.${nixpkgsBranch} {
|
pkgs = import inputs.${component.nixpkgsBranch} {
|
||||||
|
inherit (component) overlays;
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = defaultOverlays ++ [
|
|
||||||
inputs.neovim-nightly-overlay.overlays.default
|
|
||||||
];
|
|
||||||
config.allowUnfree = true;
|
|
||||||
};
|
};
|
||||||
|
neovimPackage = component.neovimPackage pkgs;
|
||||||
# Unfortunately we cannot have NixVim with Neovim-reliant
|
|
||||||
# packages such as Neovide or something similar. It has
|
|
||||||
# to be Neovim.
|
|
||||||
neovimPackages = metadata.neovimPackages pkgs;
|
|
||||||
|
|
||||||
mkNixvimConfig' = neovimPkg:
|
|
||||||
lib.nameValuePair
|
|
||||||
"${name}-${nixpkgsBranch}-${neovimPkg.name}"
|
|
||||||
(mkNixvimConfig {
|
|
||||||
inherit system pkgs;
|
|
||||||
inherit (metadata) nixvimBranch;
|
|
||||||
modules =
|
|
||||||
cfg.sharedModules
|
|
||||||
++ cfg.standaloneConfigModules
|
|
||||||
++ metadata.modules
|
|
||||||
++ [{ package = neovimPkg; }];
|
|
||||||
});
|
|
||||||
in
|
in
|
||||||
builtins.map mkNixvimConfig' neovimPackages;
|
lib.nameValuePair
|
||||||
|
"${name}-${component.nixpkgsBranch}-${neovimPackage.pname}"
|
||||||
nixvimConfigs = lib.lists.flatten
|
(mkNixvimConfig {
|
||||||
(builtins.map iterateThruBranches metadata.nixpkgsBranches);
|
inherit system pkgs;
|
||||||
|
inherit (component) nixvimBranch;
|
||||||
|
modules =
|
||||||
|
cfg.sharedModules
|
||||||
|
++ cfg.standaloneConfigModules
|
||||||
|
++ metadata.modules
|
||||||
|
++ [{ package = neovimPackage; }];
|
||||||
|
});
|
||||||
|
nixvimConfigs = builtins.map mkNixvimConfig' metadata.components;
|
||||||
in
|
in
|
||||||
lib.listToAttrs nixvimConfigs;
|
lib.listToAttrs nixvimConfigs;
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user