From 9d076b033d734be2cd02716ad43b40508bb29931 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Thu, 7 Aug 2025 14:12:17 +0100 Subject: [PATCH] tests/plugins-by-name: simplify by-name-enable-opts impl Instead of using a regex to match the absolute file path, remove the nixvim root path prefix. --- tests/plugins-by-name.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/plugins-by-name.nix b/tests/plugins-by-name.nix index fe8e9f34..2e5412d2 100644 --- a/tests/plugins-by-name.nix +++ b/tests/plugins-by-name.nix @@ -5,9 +5,12 @@ runCommandLocal, }: let + nixvim-root = ../.; by-name = ../plugins/by-name; options = lib.collect lib.isOption nixvimConfiguration.options; + toRelative = lib.removePrefix (toString nixvim-root); + # Option namespace expect by-name plugins to use namespace = "plugins"; @@ -30,15 +33,16 @@ let # Find plugins by looking for `*.*.enable` options that are declared in `plugins/by-name` by-name-enable-opts = let - regex = ''/nix/store/[^/]+/plugins/by-name/(.*)''; optionalPair = opt: file: let - result = builtins.match regex file; - in - lib.optional (result != null) { + relative = toRelative file; # Use the file name relative to `plugins/by-name/` - name = builtins.head result; + name = lib.removePrefix "plugins/by-name/" relative; + hasPrefix = name != relative; + in + lib.optional hasPrefix { + inherit name; # Use only the first two parts of the option location value = lib.genList (builtins.elemAt opt.loc) 2; };