mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
modules/dependencies: refactor all-examples
test
Embed the original `path` as an attr in the literal expression, so that we don't need to convert back from human readable paths in the test.
This commit is contained in:
parent
1095b7f891
commit
16879e3034
2 changed files with 23 additions and 7 deletions
|
@ -18,13 +18,13 @@ let
|
||||||
flutter.default = "flutter";
|
flutter.default = "flutter";
|
||||||
fzf = {
|
fzf = {
|
||||||
default = "fzf";
|
default = "fzf";
|
||||||
example = "pkgs.skim";
|
example = "skim";
|
||||||
};
|
};
|
||||||
gcc.default = "gcc";
|
gcc.default = "gcc";
|
||||||
gh.default = "gh";
|
gh.default = "gh";
|
||||||
git = {
|
git = {
|
||||||
default = "git";
|
default = "git";
|
||||||
example = [ "gitMinimal" ];
|
example = "gitMinimal";
|
||||||
};
|
};
|
||||||
glow.default = "glow";
|
glow.default = "glow";
|
||||||
go.default = "go";
|
go.default = "go";
|
||||||
|
@ -36,7 +36,7 @@ let
|
||||||
manix.default = "manix";
|
manix.default = "manix";
|
||||||
nodejs = {
|
nodejs = {
|
||||||
default = "nodejs";
|
default = "nodejs";
|
||||||
example = "pkgs.nodejs_22";
|
example = "nodejs_22";
|
||||||
};
|
};
|
||||||
plantuml.default = "plantuml";
|
plantuml.default = "plantuml";
|
||||||
ripgrep.default = "ripgrep";
|
ripgrep.default = "ripgrep";
|
||||||
|
@ -64,7 +64,21 @@ let
|
||||||
mkDependencyOption = name: properties: {
|
mkDependencyOption = name: properties: {
|
||||||
enable = lib.mkEnableOption "Add ${name} to dependencies.";
|
enable = lib.mkEnableOption "Add ${name} to dependencies.";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs name properties;
|
package =
|
||||||
|
lib.mkPackageOption pkgs name properties
|
||||||
|
# Handle example manually so that we can embed the original attr-path within
|
||||||
|
# the literalExpression object. This simplifies testing the examples.
|
||||||
|
// lib.optionalAttrs (properties ? example) {
|
||||||
|
example =
|
||||||
|
if properties.example._type or null == "literalExpression" then
|
||||||
|
properties.example
|
||||||
|
else
|
||||||
|
rec {
|
||||||
|
_type = "literalExpression";
|
||||||
|
text = "pkgs.${lib.showAttrPath path}";
|
||||||
|
path = lib.toList properties.example;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,12 +30,14 @@
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
dependencies = lib.pipe options.dependencies [
|
dependencies = lib.pipe options.dependencies [
|
||||||
(lib.filterAttrs (_: depOption: depOption.package ? example))
|
# We use a literalExpression example, with an additional `path` attr.
|
||||||
|
# This means we don't have to convert human readable paths back to list-paths for this test.
|
||||||
|
(lib.filterAttrs (_: depOption: depOption.package ? example.path))
|
||||||
(lib.mapAttrs (
|
(lib.mapAttrs (
|
||||||
_: depOption:
|
_: depOption:
|
||||||
let
|
let
|
||||||
packageName = depOption.package.example.text;
|
packagePath = depOption.package.example.path;
|
||||||
packagePath = lib.splitString "." packageName;
|
packageName = lib.showAttrPath packagePath;
|
||||||
package = lib.attrByPath packagePath (throw "${packageName} not found in pkgs") pkgs;
|
package = lib.attrByPath packagePath (throw "${packageName} not found in pkgs") pkgs;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue