feat: remove nix store path prefix if used in flakeModule

This commit is contained in:
technofab 2025-05-03 22:23:05 +02:00
parent 27696c02bc
commit 482f15c486
2 changed files with 12 additions and 4 deletions

View file

@ -1,4 +1,9 @@
{pkgs, ...}: { {
pkgs,
lib ? pkgs.lib,
self ? "",
...
}: {
mkTest = { mkTest = {
type ? "unit", type ? "unit",
name, name,
@ -7,13 +12,15 @@
actual ? null, actual ? null,
actualDrv ? null, actualDrv ? null,
pos ? null, pos ? null,
}: { }: let
fileRelative = lib.removePrefix ((toString self) + "/") pos.file;
in {
inherit type name description expected actual; inherit type name description expected actual;
actualDrv = actualDrv.drvPath or ""; actualDrv = actualDrv.drvPath or "";
pos = pos =
if pos == null if pos == null
then "" then ""
else "${pos.file}:${toString pos.line}:${toString pos.column}"; else "${fileRelative}:${toString pos.line}:${toString pos.column}";
}; };
mkSuite = name: tests: { mkSuite = name: tests: {
inherit name tests; inherit name tests;

View file

@ -1,6 +1,7 @@
{ {
flake-parts-lib, flake-parts-lib,
lib, lib,
self,
... ...
}: let }: let
inherit (lib) mkOption types; inherit (lib) mkOption types;
@ -11,7 +12,7 @@ in {
pkgs, pkgs,
... ...
}: let }: let
nixtests-lib = import ./. {inherit pkgs;}; nixtests-lib = import ./. {inherit pkgs self;};
in { in {
options.testSuites = mkOption { options.testSuites = mkOption {
type = types.attrsOf (types.listOf types.attrs); type = types.attrsOf (types.listOf types.attrs);