diff --git a/pkgs/development/interpreters/tcl/generic.nix b/pkgs/development/interpreters/tcl/generic.nix index f5d3e863361d..d5c4b775473f 100644 --- a/pkgs/development/interpreters/tcl/generic.nix +++ b/pkgs/development/interpreters/tcl/generic.nix @@ -226,7 +226,9 @@ stdenv.mkDerivation (finalAttrs: { { buildPackages }: makeSetupHook { name = "tcl-requires-check-hook"; - propagatedBuildInputs = [ buildPackages.makeBinaryWrapper ]; + substitutions = { + tcl_hook = ./tcl-requires-check-hook.tcl; + }; meta = { inherit (finalAttrs.meta) maintainers platforms; license = lib.licenses.mit; diff --git a/pkgs/development/interpreters/tcl/tcl-requires-check-hook.sh b/pkgs/development/interpreters/tcl/tcl-requires-check-hook.sh index 76c5901f2a33..6e3066d03b48 100644 --- a/pkgs/development/interpreters/tcl/tcl-requires-check-hook.sh +++ b/pkgs/development/interpreters/tcl/tcl-requires-check-hook.sh @@ -6,27 +6,8 @@ tclRequiresCheckPhase () { if [ -n "$tclRequiresCheck" ]; then export TCLLIBPATH="$out/lib $TCLLIBPATH" # Redundant if tcl-package-hook is also used - tclsh <<'EOF' - if {[info exists env(NIX_ATTRS_JSON_FILE)]} { - set nix_attrs_json_file [open $env(NIX_ATTRS_JSON_FILE)] - set nix_attrs_json [read $nix_attrs_json_file] - close $nix_attrs_json_file - # Normally we'd use one of tcllib/tdom/rl_json/yajl-tcl to parse JSON, - # however we don't want to introduce a circular dependency, - # so we rely on the JSON capabilities of the builtin sqlite package - # https://wiki.tcl-lang.org/page/SQLite+extension+JSON1 - package require sqlite3 - sqlite3 db :memory: -readonly 1 - set packages_to_check [db eval { - select value from json_each(jsonb_extract($nix_attrs_json, '$.tclRequiresCheck')) - }] - db close - } else { - set packages_to_check $env(tclRequiresCheck) - } - puts "Check whether the following packages can be required: $packages_to_check" - exit [catch {foreach pkg $packages_to_check {package require $pkg}}] -EOF + # FIXME: For some reason the output gets swallowed unless we pipe it through cat‽ + tclsh @tcl_hook@ 2>&1 | cat fi } diff --git a/pkgs/development/interpreters/tcl/tcl-requires-check-hook.tcl b/pkgs/development/interpreters/tcl/tcl-requires-check-hook.tcl new file mode 100644 index 000000000000..ee373586144a --- /dev/null +++ b/pkgs/development/interpreters/tcl/tcl-requires-check-hook.tcl @@ -0,0 +1,20 @@ +#!/usr/bin/env tclsh +if {[info exists env(NIX_ATTRS_JSON_FILE)]} { + set nix_attrs_json_file [open $env(NIX_ATTRS_JSON_FILE)] + set nix_attrs_json [read $nix_attrs_json_file] + close $nix_attrs_json_file + # Normally we'd use one of tcllib/tdom/rl_json/yajl-tcl to parse JSON, + # however we don't want to introduce a circular dependency, + # so we rely on the JSON capabilities of the builtin sqlite package + # https://wiki.tcl-lang.org/page/SQLite+extension+JSON1 + package require sqlite3 + sqlite3 db :memory: -readonly 1 + set packages_to_check [db eval { + select value from json_each(jsonb_extract($nix_attrs_json, '$.tclRequiresCheck')) + }] + db close +} else { + set packages_to_check $env(tclRequiresCheck) +} +puts "Check whether the following packages can be required: $packages_to_check" +foreach pkg $packages_to_check {package require $pkg}