dev: Move assert in derivation for generated file in the derivation definition

If we access the asserts outside the derivation arguments, and inside
the code that _creates_ the derivation then we observe IFD in `nix flake
show`.

This commit fixes it, and allows `nix flake show` to work!

Fixes #1154
This commit is contained in:
traxys 2024-07-05 21:53:05 +02:00
parent 930f5fdd21
commit 8fbcfcb469
2 changed files with 8 additions and 8 deletions

View file

@ -58,11 +58,11 @@ let
unknownTools = lib.filter (tool: !(lib.hasAttr tool packaged || lib.elem tool unpackaged)) toolList;
in
assert lib.assertMsg (lib.length unknownTools == 0)
writeText "efmls-configs-sources.nix" (
assert lib.assertMsg (lib.length unknownTools == 0)
"The following tools are neither marked as unpackaged nor as packaged: ${
lib.generators.toPretty { } unknownTools
}";
writeText "efmls-configs-sources.nix" (
"# WARNING: DO NOT EDIT\n"
+ "# This file is generated with packages.<system>.efmls-configs-sources, which is run automatically by CI\n"
+ (lib.generators.toPretty { } sources)

View file

@ -21,11 +21,11 @@ let
unpackaged ++ noPackage ++ (lib.attrNames packaged)
);
in
assert lib.assertMsg (lib.length undeclaredTool == 0)
"Undeclared tools: ${lib.generators.toPretty { } undeclaredTool}";
assert lib.assertMsg (lib.length uselesslyDeclaredTool == 0)
"Tool is not supported upstream: ${lib.generators.toPretty { } uselesslyDeclaredTool}";
writeText "efmls-configs-sources.nix" (
assert lib.assertMsg (lib.length undeclaredTool == 0)
"Undeclared tools: ${lib.generators.toPretty { } undeclaredTool}";
assert lib.assertMsg (lib.length uselesslyDeclaredTool == 0)
"Tool is not supported upstream: ${lib.generators.toPretty { } uselesslyDeclaredTool}";
"# WARNING: DO NOT EDIT\n"
+ "# This file is generated with packages.<system>.none-ls-builtins, which is run automatically by CI\n"
+ (lib.generators.toPretty { } builtinSourceNames)