You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
makeDataWriter :: input -> output -> nameOrPath -> data -> (any -> string) -> string -> string -> any -> derivation
input :: T -> string: function that takes the nix data and returns a string
output :: string: script that takes the $inputFile and write the result into $out
nameOrPath :: string: if the name contains a / the files gets written to a sub-folder of $out. The derivation name is the basename of this argument.
data :: T: the data that will be converted.
makeScriptWriter returns a derivation which creates an executable script.
Inputs {#scripts-makeScriptWriter-inputs}
config (AttrSet)
: interpreter (String)
: the interpreter to use for the script.
: check (String)
: A command to check the script. For example, this could be a linting check.
: makeWrapperArgs (Optional, [ String ], Default: [])
: Arguments forwarded to (makeWrapper)[#fun-makeWrapper].
nameOrPath (String)
: The name of the script or the path to the script.
When a string starting with "/" is passed, the script will be created at the specified path in $out.
I.e. "/bin/hello" will create a script at $out/bin/hello.
Any other string is interpreted as a filename.
It must be a POSIX filename starting with a letter, digit, dot, or underscore.
Spaces or special characters are not allowed.
content (String)
: The content of the script.
:::{.note}
This function is used as base implementation for other high-level writer functions.
For example, writeBash can (roughly) be implemented as:
nameOrPath (String)
: The name of the script or the path to the script.
When a string starting with "/" is passed, the script will be created at the specified path in $out.
For example, "/bin/hello" will create a script at $out/bin/hello.
Any other string is interpreted as a filename.
It must be a POSIX filename starting with a letter, digit, dot, or underscore.
Spaces or special characters are not allowed.
writeBabashka takes a name, an attrset with babashka interpreter and linting check (both optional)
and some babashka source code and returns an executable.
pkgs.babashka-unwrapped is used as default interpreter for small closure size. If dependencies needed, use pkgs.babashka instead. Pass empty string to check to disable the default clj-kondo linting.
:::{.note}
Babashka needs Java for fetching dependencies. Wrapped babashka contains jdk,
pass wrapped version pkgs.babashka to babashka if dependencies are required.
writeGuile returns a derivation that creates an executable Guile script.
Inputs {#scripts-writeGuile-inputs}
nameOrPath (String)
: Name of or path to the script. The semantics is the same as that of
makeScriptWriter.
config (AttrSet)
: guile (Optional, Derivation, Default: pkgs.guile)
: Guile package used for the script.
: libraries (Optional, [ Derivation ], Default: [])
: Extra Guile libraries exposed to the script.
: r6rs and r7rs (Optional, Boolean, Default: false)
: Whether to adapt Guile’s initial environment to better support R6RS/
R7RS. See the Guile Reference Manual
for details.
: srfi (Optional, [ Int ], Default: [])
: SRFI module to be loaded into the interpreter before evaluating a
script file or starting the REPL. See the Guile Reference Manual to
know which SRFI are supported.
: Other attributes are directly passed to makeScriptWriter.
makeRubyWriter takes ruby and compatible rubyPackages and produces ruby script writer,
If any libraries are specified, ruby.withPackages is used as interpreter, otherwise the "bare" ruby is used.
makeLuaWriter takes lua and compatible luaPackages and produces lua script writer,
which validates the script with luacheck at build time. If any libraries are specified,
lua.withPackages is used as interpreter, otherwise the "bare" lua is used.
writeLua takes a name an attributeset with libraries and some lua source code and
returns an executable (should also work with luajit)
Examples {#scripts-writeLua-examples}
:::{.example}
pkgs.writers.writeLua usage example
writeLua"test_lua"{libraries=[pkgs.luaPackages.say];}'' s = require("say") s:set_namespace("en") s:set('money', 'I have %s dollars') s:set('wow', 'So much money!') print(s('money', {1000})) -- I have 1000 dollars s:set_namespace("fr") -- switch to french! s:set('wow', "Tant d'argent!") print(s('wow')) -- Tant d'argent! s:set_namespace("en") -- switch back to english! print(s('wow')) -- So much money!''
writeJS takes a name an attributeset with libraries and some JavaScript sourcecode and
returns an executable
Inputs {#scripts-writeJS-inputs}
name
: 1. Function argument
attrs
: 2. Function argument
content
: 3. Function argument
Examples {#scripts-writeJS-examples}
:::{.example}
pkgs.writers.writeJS usage example
writeJS"example"{libraries=[pkgs.uglify-js];}'' var UglifyJS = require("uglify-js"); var code = "function add(first, second) { return first + second; }"; var result = UglifyJS.minify(code); console.log(result.code);''
makePythonWriter takes python and compatible pythonPackages and produces python script writer,
which validates the script with flake8 at build time. If any libraries are specified,
python.withPackages is used as interpreter, otherwise the "bare" python is used.