From 8fbcfcb469d6b55b7c93e9a939bf970fec9278e8 Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 5 Jul 2024 21:53:05 +0200 Subject: [PATCH] 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 --- flake-modules/updates/efmls-configs.nix | 8 ++++---- flake-modules/updates/none-ls.nix | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flake-modules/updates/efmls-configs.nix b/flake-modules/updates/efmls-configs.nix index 64d7f74b68..e443577b46 100644 --- a/flake-modules/updates/efmls-configs.nix +++ b/flake-modules/updates/efmls-configs.nix @@ -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) - "The following tools are neither marked as unpackaged nor as packaged: ${ - lib.generators.toPretty { } unknownTools - }"; 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 + }"; "# WARNING: DO NOT EDIT\n" + "# This file is generated with packages..efmls-configs-sources, which is run automatically by CI\n" + (lib.generators.toPretty { } sources) diff --git a/flake-modules/updates/none-ls.nix b/flake-modules/updates/none-ls.nix index 7f6b33126f..8a64284cce 100644 --- a/flake-modules/updates/none-ls.nix +++ b/flake-modules/updates/none-ls.nix @@ -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..none-ls-builtins, which is run automatically by CI\n" + (lib.generators.toPretty { } builtinSourceNames)