Loading pkgs/build-support/writers/scripts.nix +47 −0 Original line number Diff line number Diff line Loading @@ -651,6 +651,53 @@ rec { */ writeHaskellBin = name: writeHaskell "/bin/${name}"; /** writeNim takes a name, an attrset with an optional Nim compiler, and some Nim source code, returning an executable. # Examples :::{.example} ## `pkgs.writers.writeNim` usage example ```nix writeNim "hello-nim" { nim = pkgs.nim2; } '' echo "hello nim" ''; ``` ::: */ writeNim = name: { makeWrapperArgs ? [ ], nim ? pkgs.nim2, nimCompileOptions ? { }, strip ? true, }: let nimCompileCmdArgs = lib.cli.toGNUCommandLineShell { optionValueSeparator = ":"; } ( { d = "release"; nimcache = "."; } // nimCompileOptions ); in makeBinWriter { compileScript = '' cp $contentPath tmp.nim ${lib.getExe nim} compile ${nimCompileCmdArgs} tmp.nim mv tmp $out ''; inherit makeWrapperArgs strip; } name; /** writeNimBin takes the same arguments as writeNim but outputs a directory (like writeScriptBin) */ writeNimBin = name: writeNim "/bin/${name}"; /** Like writeScript but the first line is a shebang to nu Loading pkgs/build-support/writers/test.nix +27 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ let writeJSBin writeJSON writeLua writeNim writeNimBin writeNu writePerl writePerlBin Loading Loading @@ -109,6 +111,10 @@ recurseIntoAttrs { _ -> print "fail" ''); nim = expectSuccessBin (writeNimBin "test-writers-nim-bin" { } '' echo "success" ''); js = expectSuccessBin (writeJSBin "test-writers-js-bin" { libraries = [ nodePackages.semver ]; } '' var semver = require('semver'); Loading Loading @@ -191,6 +197,10 @@ recurseIntoAttrs { end ''); nim = expectSuccess (writeNim "test-writers-nim" { } '' echo "success" ''); nu = expectSuccess (writeNu "test-writers-nushell" '' echo "success" ''); Loading Loading @@ -411,6 +421,23 @@ recurseIntoAttrs { '' ); nim = expectSuccess ( writeNim "test-writers-wrapping-nim" { makeWrapperArgs = [ "--set" "ThaigerSprint" "Thailand" ]; } '' import os if getEnv("ThaigerSprint") == "Thailand": echo "success" '' ); python = expectSuccess ( writePython3 "test-writers-wrapping-python" { Loading Loading
pkgs/build-support/writers/scripts.nix +47 −0 Original line number Diff line number Diff line Loading @@ -651,6 +651,53 @@ rec { */ writeHaskellBin = name: writeHaskell "/bin/${name}"; /** writeNim takes a name, an attrset with an optional Nim compiler, and some Nim source code, returning an executable. # Examples :::{.example} ## `pkgs.writers.writeNim` usage example ```nix writeNim "hello-nim" { nim = pkgs.nim2; } '' echo "hello nim" ''; ``` ::: */ writeNim = name: { makeWrapperArgs ? [ ], nim ? pkgs.nim2, nimCompileOptions ? { }, strip ? true, }: let nimCompileCmdArgs = lib.cli.toGNUCommandLineShell { optionValueSeparator = ":"; } ( { d = "release"; nimcache = "."; } // nimCompileOptions ); in makeBinWriter { compileScript = '' cp $contentPath tmp.nim ${lib.getExe nim} compile ${nimCompileCmdArgs} tmp.nim mv tmp $out ''; inherit makeWrapperArgs strip; } name; /** writeNimBin takes the same arguments as writeNim but outputs a directory (like writeScriptBin) */ writeNimBin = name: writeNim "/bin/${name}"; /** Like writeScript but the first line is a shebang to nu Loading
pkgs/build-support/writers/test.nix +27 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ let writeJSBin writeJSON writeLua writeNim writeNimBin writeNu writePerl writePerlBin Loading Loading @@ -109,6 +111,10 @@ recurseIntoAttrs { _ -> print "fail" ''); nim = expectSuccessBin (writeNimBin "test-writers-nim-bin" { } '' echo "success" ''); js = expectSuccessBin (writeJSBin "test-writers-js-bin" { libraries = [ nodePackages.semver ]; } '' var semver = require('semver'); Loading Loading @@ -191,6 +197,10 @@ recurseIntoAttrs { end ''); nim = expectSuccess (writeNim "test-writers-nim" { } '' echo "success" ''); nu = expectSuccess (writeNu "test-writers-nushell" '' echo "success" ''); Loading Loading @@ -411,6 +421,23 @@ recurseIntoAttrs { '' ); nim = expectSuccess ( writeNim "test-writers-wrapping-nim" { makeWrapperArgs = [ "--set" "ThaigerSprint" "Thailand" ]; } '' import os if getEnv("ThaigerSprint") == "Thailand": echo "success" '' ); python = expectSuccess ( writePython3 "test-writers-wrapping-python" { Loading