-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Is your feature request related to a problem? Please describe.
Similar to nix-community/nix-unit#270, I'm facing the issue that building .#checks.x86_64-linux.lib-tests fails if there are needed inputs in the flake that are not a top-level input.
Reproduce the issue easily with:
nix build -L gitlab:moduon/polytropos/f9c821ca254a78c1d5670480668a219643f87e04#checks.x86_64-linux.lib-tests
[...]
lib-tests> warning: error: unable to download 'https://github.com/nix-community/dream2nix/archive/69eb01fa0995e1e90add49d8ca5bcba213b0416f.tar.gz': Could not resolve hostname (6) Could not resolve host: github.com; retrying in 2386 ms
lib-tests> ☢️ testMapByOdooAttrs
lib-tests> error:
lib-tests> … while calling the 'foldl'' builtin
lib-tests> at /build/.local/share/nix/root/nix/store/bxfbn4a6l0ji3pb6mzwsp3nybrpzrvv2-source/lib/attrsets.nix:374:26:
lib-tests> 373| */
lib-tests> 374| concatMapAttrs = f: v: foldl' mergeAttrs { } (attrValues (mapAttrs f v));
lib-tests> | ^
lib-tests> 375|
lib-tests>
lib-tests> … while calling the 'attrValues' builtin
lib-tests> at /build/.local/share/nix/root/nix/store/bxfbn4a6l0ji3pb6mzwsp3nybrpzrvv2-source/lib/attrsets.nix:374:49:
lib-tests> 373| */
lib-tests> 374| concatMapAttrs = f: v: foldl' mergeAttrs { } (attrValues (mapAttrs f v));
lib-tests> | ^
lib-tests> 375|
lib-tests>
lib-tests> (stack trace truncated; use '--show-trace' to show the full, detailed trace)
lib-tests>
lib-tests> error: Failed to open archive (Source threw exception: error: unable to download 'https://github.com/nix-community/dream2nix/archive/69eb01fa0995e1e90add49d8ca5bcba213b0416f.tar.gz': Could not resolve hostname (6) Could not resolve host: github.com)
lib-tests>
lib-tests>
lib-tests> 😢 0/1 successful
lib-tests> error: Tests failedDescribe the solution you'd like
The nix-unit flake-parts module supports setting allowNetwork = true, and that does a fancy FOD trick to make the test safely online:
- Configure the check as a FOD.
- Use the derivation
outPathas the text that will be written to$out - Use the derivation
outPathhash as the FOD check.
I'd love to be able to create a lib.online-tests output and that it behaved just like lib.tests (create a check), but this time a FOD+IFD automatic check that won't ask me to fill my flake with unnecessary inputs.
Describe alternatives you've considered
I added all sub-inputs as top-level inputs and wire them with follows. Test it:
nix build -L gitlab:moduon/polytropos/684a45fb3708ad6a40d21de74bcc402d02fed539#checks.x86_64-linux.lib-tests
[...]
lib-tests> ✅ testMapByOdooAttrs
lib-tests>
lib-tests> 🎉 1/1 successfulThis makes the check pass, but pollutes my flake.nix with lots of information that I don't really need.
Additional context
@moduon MT-9