diff --git a/pkgs/development/interpreters/racket/minimal.nix b/pkgs/development/interpreters/racket/minimal.nix index f8dfc270630c2..9d0a57f9a1f67 100644 --- a/pkgs/development/interpreters/racket/minimal.nix +++ b/pkgs/development/interpreters/racket/minimal.nix @@ -13,6 +13,8 @@ disableDocs ? false, callPackage, + + writers, }: let @@ -117,12 +119,31 @@ stdenv.mkDerivation (finalAttrs: { ''; passthru = { + # Functionalities # + writeScript = + nameOrPath: + { + libraries ? [ ], + ... + }@config: + assert lib.assertMsg (libraries == [ ]) "library integration for Racket has not been implemented"; + writers.makeScriptWriter ( + builtins.removeAttrs config [ "libraries" ] + // { + interpreter = "${lib.getExe finalAttrs.finalPackage}"; + } + ) nameOrPath; + writeScriptBin = name: finalAttrs.passthru.writeScript "/bin/${name}"; + # Tests # tests = builtins.mapAttrs (name: path: callPackage path { racket = finalAttrs.finalPackage; }) { ## Basic ## write-greeting = ./tests/write-greeting.nix; get-current-launcher-variant = ./tests/get-current-launcher-variant.nix; load-libs = ./tests/load-libs.nix; + + ## Nixpkgs supports ## + nix-write-script = ./tests/nix-write-script.nix; }; }; diff --git a/pkgs/development/interpreters/racket/tests/nix-write-script.nix b/pkgs/development/interpreters/racket/tests/nix-write-script.nix new file mode 100644 index 0000000000000..5fa50ea195872 --- /dev/null +++ b/pkgs/development/interpreters/racket/tests/nix-write-script.nix @@ -0,0 +1,26 @@ +{ runCommandLocal, racket }: + +let + script = racket.writeScript "racket-test-nix-write-script-the-script" { } '' + #lang racket/base + (display "success") + (newline) + ''; +in + +runCommandLocal "racket-test-nix-write-script" + { + nativeBuildInputs = [ racket ]; + } + '' + expectation="success" + + output="$(${script})" + + if test "$output" != "$expectation"; then + echo "output mismatch: expected ''${expectation}, but got ''${output}" + exit 1 + fi + + touch $out + ''