mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
flake: add auto
flake-parts module
When enabled, automatically sets up packages and/or checks for all `nixvimConfigurations`
This commit is contained in:
parent
8fb2fe22c2
commit
e793c5cdc6
2 changed files with 63 additions and 0 deletions
62
flake/flake-modules/auto.nix
Normal file
62
flake/flake-modules/auto.nix
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.nixvim;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.nixvim = {
|
||||||
|
packages = {
|
||||||
|
enable = lib.mkEnableOption "automatically installing packages for each nixvimConfigurations";
|
||||||
|
nameFunction = lib.mkOption {
|
||||||
|
type = lib.types.functionTo lib.types.str;
|
||||||
|
description = ''
|
||||||
|
A function to convert a nixvimConfiguration's name into a package name.
|
||||||
|
|
||||||
|
**Type**
|
||||||
|
|
||||||
|
```
|
||||||
|
String -> String
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
default = name: "nixvim-" + name;
|
||||||
|
defaultText = lib.literalExpression ''name: "nixvim-" + name'';
|
||||||
|
example = lib.literalExpression ''name: name + "-nvim"'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
checks = {
|
||||||
|
enable = lib.mkEnableOption "automatically installing checks for each nixvimConfigurations";
|
||||||
|
nameFunction = lib.mkOption {
|
||||||
|
type = lib.types.functionTo lib.types.str;
|
||||||
|
description = ''
|
||||||
|
A function to convert a nixvimConfiguration's name into a check name.
|
||||||
|
|
||||||
|
**Type**
|
||||||
|
|
||||||
|
```
|
||||||
|
String -> String
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
default = name: "nixvim-" + name;
|
||||||
|
defaultText = lib.literalExpression ''name: "nixvim-" + name'';
|
||||||
|
example = lib.literalExpression ''name: "nixvim-" + name + "-test"'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
perSystem =
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
packages = lib.mkIf cfg.packages.enable (
|
||||||
|
lib.mapAttrs' (name: configuration: {
|
||||||
|
name = cfg.packages.nameFunction name;
|
||||||
|
value = configuration.config.build.package;
|
||||||
|
}) config.nixvimConfigurations
|
||||||
|
);
|
||||||
|
checks = lib.mkIf cfg.checks.enable (
|
||||||
|
lib.mapAttrs' (name: configuration: {
|
||||||
|
name = cfg.checks.nameFunction name;
|
||||||
|
value = configuration.config.build.test;
|
||||||
|
}) config.nixvimConfigurations
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ let
|
||||||
defaultModules = {
|
defaultModules = {
|
||||||
nixvimModules = ./nixvimModules.nix;
|
nixvimModules = ./nixvimModules.nix;
|
||||||
nixvimConfigurations = ./nixvimConfigurations.nix;
|
nixvimConfigurations = ./nixvimConfigurations.nix;
|
||||||
|
auto = ./auto.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Modules for the flakeModules output, but not the default module
|
# Modules for the flakeModules output, but not the default module
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue