Hi folks,
For some time I Unit Test my custom functions. I simply use the default runTests that I execute by nix eval.
Everything works as expected including testing some semi-pure functions like:
{
yamlToJson =
inp:
builtins.fromJSON (
builtins.readFile (
runCommandLocal "my-data"
{
inherit inp;
passAsFile = [ "inp" ];
}
''
${pkgs.remarshall}/bin/remarshal \
-if yaml \
-of json \
-i "''${inpPath}" \
-o "''${out}"
''
)
);
}
Today I added a flake input path:/a/b/c which is a flake to build my Rust application. I also added a function like this:
{
getSomeCustomData =
inp:
builtins.fromJSON (
builtins.readFile (
runCommandLocal "my-data"
{
inherit inp;
passAsFile = [ "inp" ];
}
''
${pkgs.myrustapp}/bin/myrustapp \
abc \
--xyz "''${inpPath}" \
> "''${out}"
''
)
);
}
And I wrote a unit test for it. And it works OK - I can run nix eval.
The only problem is that the nix eval takes more than 2 minutes to execute.
Of course for the first time this should take a few minutes to build the Rust app. But then the binary should be in /nix/store and the flake should be locked in Flake.lock.
But no, every execution of nix eval takes a few minutes.
While I’m waiting I get:
copying '«path:/a/b/c?lastModified=1761904727&narHash=sha256-O50S9JSPG7RUByZJE%2B60EJtTLSx%2BmU90IdtxlUVM5Rs%3D»/' to the store
(this is the flake input - the rust app)
and then
copying '/nix/store/ybksbvmjmac5jq2mhginzwldifjqwgw7-source'
(this is a copy of the flake input - the Rust app source)
I don’t understand why it is doing all the work (all the copying) and why it is taking so long. The app is already compiled and the binary is in /nix/store and execution of the app takes less than a second. Do you have any idea what’s wrong?
Thank you.