nix-wrapper-modules
A Nix library to create wrapped executables via the module system.
Are you annoyed by rewriting modules for every platform? nixos, home-manager, nix-darwin, devenv?
Then this library is for you!
What is this for?
When configuring programs using nix, one of the highlights for most is the module system.
The main “configuration.nix” file of NixOS and “home.nix” for home-manager contain all sorts of shortlist options. For a while, it’s great!
But then you need to use your configuration somewhere else. Pulling in your home-manager configuration on some other machine is usually overkill, takes too long, and is often a destructive action, as it will link files into the home directory and move the old files.
You don’t want to pull in your entire home environment, you just needed to do some pair programming and wanted to use some of your tools, not destroy your co-workers dotfiles. Can’t you make like, a shell, or a derivation or something and use that directly?
In addition, you often have some modules that might be duplicated because NixOS or home-manager options can be different. And you can’t use any of that in a shell. It is starting to wear on you a bit.
So you hear about this thing called “wrapping” a package. This means, writing a script that launches the program with specific arguments or variables set, and installing that instead.
Then, you could have your configured tools as derivations you can just install via any means nix has of installing something.
Nix makes this concept very powerful, as you can create files and pull in other programs without installing them globally.
Your first attempt, you might write something that looks like this:
pkgs.writeShellScriptBin "alacritty" (let
tomlcfg = pkgs.writeText "alacritty.toml" ''
[terminal.shell]
program = "${pkgs.zsh}/bin/zsh"
args = [ "-l" ]
'';
in ''
exec ${pkgs.alacritty}/bin/alacritty --config-file ${tomlcfg} "$@"
'')
This is good! Kinda. If you install it, it will install the wrapper script instead of the program, and the script tells it where the config is! And it doesn’t need home-manager or NixOS!
But on closer inspection, its missing a lot. What if this were a package with a few more things you could launch? Where is the desktop file? Man pages?
So, your next attempt might look more like this:
pkgs.symlinkJoin (let
tomlcfg = pkgs.writeText "alacritty.toml" ''
[terminal.shell]
program = "${pkgs.zsh}/bin/zsh"
args = [ "-l" ]
'';
in {
name = "alacritty";
paths = [ pkgs.alacritty ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/alacritty --add-flag --config-file --add-flag ${tomlcfg}
'';
})
Ok. So maybe that isn’t your second try. But you get there eventually.
This is a little closer to how stuff like nixvim works, if you have heard of it. It just has a lot more on top of that.
But even this has problems. If you want to have any sensible ability to override this later, for example, you will need to add that ability yourself.
You also now have a desktop file that might point to the wrong place. And if all you wanted to do was set a setting or 2 and move on, all of that will still be necessary to deal with.
You eventually are reduced to going to the source code of a bunch of modules in nixpkgs or home-manager and copy pasting what they did into your wrapper.
What if I told you, you can solve all those problems, and gain a really nice, consistent, and flexible way to do this, and make sure it can always be overridden later?
And it uses something you already know! The module system!
inputs.nix-wrapper-modules.wrappers.alacritty.wrap {
inherit pkgs;
settings.terminal.shell.program = "${pkgs.zsh}/bin/zsh";
settings.terminal.shell.args = [ "-l" ];
}
The above snippet does everything the prior 2 examples did, and then some!
That’s a full module (defined like this and with docs here) but just for that package, and the result is a fully portable derivation, just like the wrapper scripts above!
And you can call .wrap on it as many times as you want! You can define your own options
to easily toggle things for your different use cases and re-export it in a flake and change them on import, etc.
And you do not lose your ability to use .override or .overrideAttrs on the original package!
The arguments will be passed through to the value of config.package,
and the result will persist within the module system for future evaluations!
As a result it is safe to replace the vast majority of packages with their wrapped counterpart in an overlay directly.
There are included modules for several programs already, but there are rich and easy to use options defined for creating your own modules as well!
If you make one, you are encouraged to submit it here for others to use if you wish!
For more information on how to do this, check out the getting started documentation, and the descriptions of the module options you have at your disposal!
Long-term Goals
It is the ideal of this project to become a hub for everyone to contribute, so that we can all enjoy our portable configurations with as little individual strife as possible.
In service of that ideal, the immediate goal would be to transfer this repo to nix-community the moment that becomes an option.
Eventually I hope to have wrapper modules in nixpkgs, but again, nix-community would be the first step.
Short-term Goals
Help us add more modules! Contributors are what makes projects like these which contain modules for so many programs amazing!
Why rewrite lassulus/wrappers?
Yes, I know about this comic (xkcd 927), but it was necessary that I not heed the warning it gives.
For those paying attention to the recent nix news, you may have heard of a similar project which was released recently.
This excellent video by Vimjoyer was made, which mentions the project this one is inspired by at the end.
The video got that repository a good amount of attention. And the idea of the .apply interface was quite good, although I did implement it in my own way.
Most of the video is still applicable though! It is short and most of its runtime is devoted to explaining the problem being solved. So, if you still find yourself confused as to what problem this repository is solving, please watch it!
But the mentioned project gives you very little control from within the module system over what is being built as your wrapper derivation. (the thing you are actually trying to create)
It was designed around a module system which can supply some of the arguments of some separate builder function designed to be called separately, which itself does not give full control over the derivation.
This repository was designed around giving you absolute control over the derivation your wrapper is creating from within the module system, and defining modules for making the experience making wrapper modules great.
In short, this repo is more what it claims to be. A generalized and effective module system for creating wrapper derivations, and offers far more abilities to that effect to the module system itself.
This allows you to easily modify your module with extra files and scripts or whatever else you may need!
Maybe you want your tmux wrapper to also output a launcher script that rejoins a session, or creates one? You can do that using this project with, for example, a drv.postBuild hook! Just like in a derivation, and you can even use "${placeholder "out"}" in it!
But you can supply it from within the module system! You could then define an option to customize its behavior later!
In addition, the way it is implemented allows for the creation of helper modules that wrap derivations in all sorts of ways, which you could import instead of wlib.modules.default if you wanted. We could have similar modules for wrapping projects via bubblewrap or into docker containers with the same ease with which this library orchestrates regular wrapper scripts.
It makes a lot of improvements, both to the basic wrapping options, and to the module system as a whole.
Things like:
- A
wlib.types.subWrapperModuleWithtype which works likelib.types.submoduleWith(and can be used in other things which use the nixpkgs module system) - Fine-grained control over the actual wrapper derivation you are making with options like
config.drvandconfig.passthru(and others…) - You can call
.extendModulesfrom the evaluated result without problems. - A customizable type which normalizes “specs” for you,
wlib.types.specWith/wlib.types.spec. wlib.types.dagOf(set form) andwlib.types.dalOf(list form) use thespectype to normalize a list or set of values or specs to a form sortable bywlib.dag.topoSort- And for the wrapper script generation options:
- The full suite of options you are used to from
pkgs.makeWrapper, but in module form, and with full control of the order even across options. - Choose between multiple backend implementations with a single line of code without changing any other options:
nixwhich is the default, likeshellbut allows runtime variable expansion rather than build timeshellwhich usespkgs.makeWrapperbinarywhich usespkgs.makeBinaryWrapper
${placeholder "out"}works correctly in this module, pointing to the final wrapper derivation- Ordering of flags on a fine-grained basis (via the DAG and DAL types mentioned above)
- Customizing of flag separator per item (via those same types)
- Customizing of escaping function per item (same thing here…)
- and more…
- The full suite of options you are used to from
- and more…
While both projects have surface level similarities, this repository is in fact a full rewrite, with a quite significant increase in functionality!
Getting Started
Overview
This library provides two main components:
It provides the core system via its lib output, internally called wlib
lib.evalModule: Function to create reusable wrapper modules with type-safe configuration options- And related:
lib.evalPackage: an alias forevalModulewhich returns the package directlylib.wrapPackage, which is the same but pre-imports thewlib.modules.defaultmodule for convenience in creating ad-hoc wrappers- A module implementation of
pkgs.makeWrapperand friends. - Several useful nix module system types.
- etc…
- And related:
And it serves as a repository for modules for wrapping the programs themselves, allowing knowledge to be shared for you to use!
For that it offers:
wlib.wrapperModules: Pre-made wrapper modules for common packages (tmux,wezterm, etc.)outputs.wrappers: a flake output containing partially evaluated forms of the modules inwrapperModulesfor easier access to.wrapand other values in the module system directly.
Usage
Note: there are also template(s) you can access via nix flake init -t github:Birdeehub/nix-wrapper-modules
They will get you started with a module file and the default one also gives you a flake which imports it, for quickly testing it out!
Using Pre-built Wrapper Modules
{
description = ''
A flake providing a wrapped `wezterm` package with an extra keybind!
'';
inputs.wrappers.url = "github:BirdeeHub/nix-wrapper-modules";
outputs = { self, wrappers }: {
# These things work without flakes too,
# but this gives an example from start to finish!
packages.x86_64-linux.default = wrappers.lib.evalPackage
({ config, lib, wlib, pkgs, ... }: {
pkgs = wrappers.inputs.nixpkgs.legacyPackages.x86_64-linux;
imports = [ wlib.wrapperModules.wezterm ];
luaInfo = {
keys = [
{
key = "F12";
mods = "SUPER|CTRL|ALT|SHIFT";
action = lib.generators.mkLuaInline "wezterm.action.Nop";
}
];
};
});
};
}
{
description = ''
A flake providing a wrapped `mpv` package with some configuration
'';
inputs.wrappers.url = "github:BirdeeHub/nix-wrapper-modules";
inputs.wrappers.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs, wrappers }: let
forAllSystems = with nixpkgs.lib; genAttrs platforms.all;
in {
packages = forAllSystems (system: {
default = wrappers.wrappers.mpv.wrap (
{config, wlib, lib, pkgs, ...}: {
pkgs = import nixpkgs { inherit system; };
scripts = [ pkgs.mpvScripts.mpris ];
"mpv.conf".content = ''
vo=gpu
hwdec=auto
'';
"mpv.input".content = ''
WHEEL_UP seek 10
WHEEL_DOWN seek -10
'';
}
);
});
};
}
Extending Configurations
The .eval function allows you to extend an already-applied configuration with additional modules, similar to extendModules in NixOS.
The .apply function works the same way, but automatically grabs .config from the result of .eval for you,
so you can have .wrap and .apply more easily available without evaluating.
The .wrap function works the same way, but automatically grabs .config.wrapper (the final package) from the result of .eval for you.
The package (via passthru) and the modules under .config both offer all 3 functions.
# Apply initial configuration
# you can use `.eval` `.apply` or `.wrap` for this.
initialConfig = (inputs.wrappers.wrappers.tmux.eval ({config, pkgs, ...}{
# but if you don't plan to provide pkgs yet, you can't use `.wrap` or `.wrapper` yet.
# config.pkgs = pkgs;
# but we can still use `pkgs` before that inside!
config.plugins = [ pkgs.tmuxPlugins.onedark-theme ];
config.clock24 = false;
})).config;
# Extend with additional configuration!
extendedConfig = initialConfig.apply {
modeKeys = "vi";
statusKeys = "vi";
vimVisualKeys = true;
};
# Access the wrapper!
# apply is useful because we don't need to give it `pkgs` but it gives us
# top level access to `.wrapper`, `.wrap`, `.apply`, and `.eval`
# without having to grab `.config` ourselves
actualPackage = extendedConfig.wrap { inherit pkgs; };
# since we didn't supply `pkgs` yet, we must pass it `pkgs`
# before we are given the new value of `.wrapper` from `.wrap`
# Extend it again! You can call them on the package too!
apackage = (actualPackage.eval {
prefix = "C-Space";
}).config.wrapper; # <-- `.wrapper` to access the package direcly
# and again! `.wrap` gives us back the package directly
# all 3 forms take modules as an argument
packageAgain = apackage.wrap ({config, pkgs, ...}: {
# list definitions append when declared across modules by default!
plugins = [ pkgs.tmuxPlugins.fzf-tmux-url ];
});
Creating Custom Wrapper Modules
inputs:
(inputs.wrappers.lib.evalModule ({ config, wlib, lib, pkgs, ... }: {
# You can only grab the final package if you supply pkgs!
# But if you were making it for someone else, you would want them to do that!
# config.pkgs = pkgs;
# include wlib.modules.makeWrapper and wlib.modules.symlinkScript
imports = [ wlib.modules.default ];
# The core options are focused on building a wrapper derivation.
# different wrapper options may be implemented on top, for things like bubblewrap or other tools.
# `wlib.modules.default` gives you a great module-based pkgs.makeWrapper to use.
options = {
profile = lib.mkOption {
type = lib.types.enum [ "fast" "quality" ];
default = "fast";
description = "Encoding profile to use";
};
outputDir = lib.mkOption {
type = lib.types.str;
default = "./output";
description = "Directory for output files";
};
};
config.package = pkgs.ffmpeg;
config.flags = {
"-preset" = if config.profile == "fast" then "veryfast" else "slow";
};
config.env = {
FFMPEG_OUTPUT_DIR = config.outputDir;
};
})) # .config.wrapper to grab the final package! Only works if pkgs was supplied.
wrapPackage comes with wlib.modules.default already included, and outputs the package directly!
Use this for quickly creating a one-off wrapped program within your configuration!
inputs: # <- get the lib somehow
{ pkgs, ... }: {
home.shellAliases = let
curlwrapped = inputs.wrappers.lib.wrapPackage ({ config, wlib, lib, ... }: {
inherit pkgs; # you can only grab the final package if you supply pkgs!
package = pkgs.curl;
extraPackages = [ pkgs.jq ];
env = {
CURL_CA_BUNDLE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
};
flags = {
"--silent" = true;
"--connect-timeout" = "30";
};
flagSeparator = "="; # Use --flag=value instead of --flag value (default is " ")
runShell = [
''
echo "Making request..." >&2
''
];
});
in {
runCurl = "${lib.getExe curlwrapped}";
};
}
nixos, home-manager, And Friends
Because it uses the regular module system and evaluates as a lib.types.submodule option,
this library has excellent integration with nixos, home-manager, nix-darwin and any other such systems.
With a single, simple function, you can use any wrapper module directly as a module in configuration.nix or home.nix!
# in a nixos module
{ ... }: {
imports = [
(inputs.wrappers.lib.mkInstallModule { name = "tmux"; value = inputs.wrappers.lib.wrapperModules.tmux; })
];
wrappers.tmux = {
enable = true;
modeKeys = "vi";
statusKeys = "vi";
vimVisualKeys = true;
};
}
# in a home-manager module
{ config, lib, ... }: {
imports = [
(inputs.wrappers.lib.mkInstallModule {
loc = [ "home" "packages" ];
name = "neovim";
value = inputs.wrappers.lib.wrapperModules.neovim;
})
];
wrappers.neovim = { pkgs, lib, ... }: {
enable = true;
settings.config_directory = ./nvim;
specs.stylix = {
data = pkgs.vimPlugins.mini-base16;
before = [ "INIT_MAIN" ];
info = lib.filterAttrs (
k: v: builtins.match "base0[0-9A-F]" k != null
) config.lib.stylix.colors.withHashtag;
config = /* lua */ ''
local info, pname, lazy = ...
require("mini.base16").setup({ palette = info, })
'';
};
};
home.sessionVariables = let
# You can still grab the value from config if desired!
nvimpath = lib.getExe config.wrappers.neovim.wrapper;
in {
EDITOR = nvimpath;
MANPAGER = "${nvimpath} +Man!";
};
}
See the wlib.mkInstallModule documentation for more info!
flake-parts
This repository also offers a flake-parts module!
It offers a template! nix flake init -t github:BirdeeHub/nix-wrapper-modules#flake-parts
{
description = ''
Uses flake-parts to set up the flake outputs:
`wrappers`, `wrapperModules` and `packages.*.*`
'';
inputs.wrappers.url = "github:BirdeeHub/nix-wrapper-modules";
inputs.wrappers.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
outputs =
{
self,
nixpkgs,
wrappers,
flake-parts,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.platforms.all;
# Import the flake-parts module:
imports = [ wrappers.flakeModules.wrappers ];
perSystem =
{ pkgs, ... }:
{
# wrappers.pkgs = pkgs; # choose a different `pkgs`
wrappers.control_type = "exclude"; # | "build" (default: "exclude")
wrappers.packages = {
alacritty = true; # <- set to true to exclude from being built into `packages.*.*` flake output
};
};
flake.wrappers.alacritty = { pkgs, wlib, ... }: {
imports = [ wlib.wrapperModules.alacritty ];
settings.terminal.shell.program = "${pkgs.zsh}/bin/zsh";
settings.terminal.shell.args = [ "-l" ];
};
flake.wrappers.tmux =
{ wlib, pkgs, ... }:
{
imports = [ wlib.wrapperModules.tmux ];
plugins = with pkgs.tmuxPlugins; [ onedark-theme ];
};
flake.wrappers.xplr = wrappers.lib.wrapperModules.xplr;
};
}
The above flake will export the partially evaluated submodule from outputs.wrappers as it shows.
However, it also offers the values in importable form from outputs.wrapperModules for you!
In addition to that, it will build packages.*.* for each of the systems and wrappers for you.
perSystem.wrappers options control which packages get built, and with what pkgs.
wrappers.control_type controls how wrappers.packages is handled.
If wrappers.control_type is "exclude", then including true for a value will exclude its packages output.
If you change it to "build", then you must include true for all you want to be built.
wlib documentation
Generated documentation for the wlib library.
Contains the main module evaluation function, and various other useful items.
wlib main set documentation
wlib.evalModules
calls nixpkgs.lib.evalModules with the core module imported and wlib added to specialArgs
wlib.evalModules takes the same arguments as nixpkgs.lib.evalModules
wlib.evalModule
evalModule = module: wlib.evalModules { modules = lib.toList module; };
Evaluates the module along with the core options, using lib.evalModules
Takes a module (or list of modules) as its argument.
Returns the result from lib.evalModules directly.
To submit a module to this repo, this function must be able to evaluate it.
The wrapper module system integrates with NixOS module evaluation:
- Uses
lib.evalModulesfor configuration evaluation - Supports all standard module features (imports, conditionals, mkIf, etc.)
- Provides
configfor accessing evaluated configuration - Provides
optionsfor introspection and documentation
wlib.evalPackage
evalPackage = module: (wlib.evalModules { modules = lib.toList module; }).config.wrapper;
Evaluates the module along with the core options, using lib.evalModules
Takes a module (or list of modules) as its argument.
Returns the final wrapped package from eval_result.config.wrapper directly.
Requires a pkgs to be set.
home.packages = [
(wlib.evalPackage [
{ inherit pkgs; }
({ pkgs, wlib, lib, ... }: {
imports = [ wlib.modules.default ];
package = pkgs.hello;
flags."--greeting" = "greetings!";
})
])
(wlib.evalPackage [
{ inherit pkgs; }
({ pkgs, wlib, lib, ... }: {
imports = [ wlib.wrapperModules.tmux ];
plugins = [ pkgs.tmuxPlugins.onedark-theme ];
})
])
];
wlib.mkInstallModule
Produces a module for another module system, that can be imported to configure and/or install a wrapper module.
Arguments:
{
name, # string
value, # module or list of modules
optloc ? [ "wrappers" ],
loc ? [
"environment"
"systemPackages"
],
as_list ? true,
# Also accepts any valid top-level module attribute
# other than `config` or `options`
...
}:
Creates a wlib.types.subWrapperModule option with an extra enable option at
the path indicated by optloc ++ [ name ], with the default optloc being [ "wrappers" ]
Defines a list value at the path indicated by loc containing the .wrapper value of the submodule,
with the default loc being [ "environment" "systemPackages" ]
If as_list is false, it will set the value at the path indicated by loc as it is,
without putting it into a list.
This means it will create a module that can be used like so:
# in a nixos module
{ ... }: {
imports = [
(mkInstallModule { name = "?"; value = someWrapperModule; })
];
config.wrappers."?" = {
enable = true;
env.EXTRAVAR = "TEST VALUE";
};
}
# in a home-manager module
{ ... }: {
imports = [
(mkInstallModule { name = "?"; loc = [ "home" "packages" ]; value = someWrapperModule; })
];
config.wrappers."?" = {
enable = true;
env.EXTRAVAR = "TEST VALUE";
};
}
If needed, you can also grab the package directly with config.wrappers."?".wrapper
Note: This function will try to provide a pkgs to the subWrapperModule automatically.
If the target module evaluation does not provide a pkgs via its module arguments to use,
you will need to supply it to the submodule yourself later.
wlib.wrapModule
Imports wlib.modules.default then evaluates the module. It then returns .config so that .wrap is easily accessible!
Use this when you want to quickly create a wrapper but without providing it a pkgs yet.
Equivalent to:
wrapModule = (wlib.evalModule wlib.modules.default).config.apply;
Example usage:
helloWrapper = wrapModule ({ config, wlib, pkgs, ... }: {
options.greeting = lib.mkOption {
type = lib.types.str;
default = "hello";
};
config.package = pkgs.hello;
config.flags = {
"--greeting" = config.greeting;
};
};
# This will return a derivation that wraps the hello package with the --greeting flag set to "hi".
helloWrapper.wrap {
pkgs = pkgs;
greeting = "hi";
};
wlib.wrapPackage
Imports wlib.modules.default then evaluates the module. It then returns the wrapped package.
Use this when you want to quickly create a wrapped package directly, which does not have an existing module already.
Requires a pkgs to be set.
Equivalent to:
wrapPackage = module: wlib.evalPackage ([ wlib.modules.default ] ++ toList module);
wlib.mkOutOfStoreSymlink
mkOutOfStoreSymlink :: pkgs -> path -> { out = …; … }
Lifted straight from home manager, but requires pkgs to be passed to it first.
Creates a symlink to a local absolute path, does not check if it is a store path first.
Returns a store path that can be used for things which require a store path.
wlib.getPackageOutputsSet
getPackageOutputsSet :: Derivation -> AttrSet
Given a package derivation, returns an attribute set mapping each of its output names (e.g. “out”, “dev”, “doc”) to the corresponding output path.
This is useful when a wrapper or module needs to reference multiple outputs of a single derivation. If the derivation does not define multiple outputs, an empty set is returned.
Example: getPackageOutputsSet pkgs.git => { out = /nix/store/…-git; man = /nix/store/…-git-man; }
wlib.escapeShellArgWithEnv
Escape a shell argument while preserving environment variable expansion.
This escapes backslashes and double quotes to prevent injection, then
wraps the result in double quotes.
Unlike lib.escapeShellArg which uses single quotes, this allows
environment variable expansion (e.g., $HOME, ${VAR}).
Caution! This is best used by the nix backend for wlib.modules.makeWrapper to escape things,
because the shell and binary implementations pass their args to pkgs.makeWrapper at build time,
so allowing variable expansion may not always do what you expect!
Example
escapeShellArgWithEnv "$HOME/config.txt"
=> "\"$HOME/config.txt\""
escapeShellArgWithEnv "/path/with\"quote"
=> "\"/path/with\\\"quote\""
escapeShellArgWithEnv "/path/with\\backslash"
=> "\"/path/with\\\\backslash\""
wlib.makeCustomizable
Wrap a function (or callable attribute set) to make it customizable via a named override entry.
A slightly generalized version of nixpkgs.lib.makeOverridable, with explicit
support for:
- custom override names
- configurable argument-merging semantics
- preserving override entry points across common derivation-like patch
functions (e.g.
override,overrideAttrs,overrideDerivation)
This helper turns f into a functor that:
- Preserves the original argument signature of
f - Exposes an override function under the attribute
${name} - Recomputes
fwhen arguments are overridden - Re-attaches
${name}to selected callable attributes on the result off, so that chaining through derivation-style patch functions does not lose the custom override entry
Signature:
makeCustomizable =
name:
{
patches ? [
"override"
"overrideAttrs"
"overrideDerivation"
],
mergeArgs ?
origArgs: newArgs:
origArgs // (if lib.isFunction newArgs then newArgs origArgs else newArgs),
}@opts:
f:
Parameters:
-
name: The attribute name under which the override function is exposed (e.g.customize,withPackages). This attribute is attached both tofitself and to applicable results returned by callingf. -
opts.patches: A list of attribute names on the result offthat should propagate the named override. Each listed attribute is expected to be callable when present. This is primarily intended for derivation-like results, ensuring that calling methods such asoverride,overrideAttrs, oroverrideDerivationpreserves the custom override entry rather than discarding it. It will only patch the value if present. -
opts.mergeArgs: A function controlling how new arguments are merged with the original arguments when overriding. It receivesorigArgsandnewArgsand must return the argument used to re-invokef. By default, this performs a shallow merge, evaluatingnewArgsif it is a function. -
f: The function (or callable attribute set) to wrap. Iffis an attribute set, its additional attributes are preserved, and an existing${name}entry (if present) is composed rather than replaced.
Semantics:
- Argument overrides recompute
fwith merged arguments. - Result-level patches recompute
fand then delegate to the corresponding callable attribute on the result. - Returned attribute sets and functions gain a
${name}attribute that can be chained arbitrarily.
Example:
luaEnv = wlib.makeCustomizable
"withPackages"
{ mergeArgs = og: new: lp: og lp ++ new lp; }
pkgs.luajit.withPackages
(lp: [ lp.inspect ]);
# inspect + cjson
luaEnv2 = luaEnv.withPackages (lp: [ lp.cjson ]);
# inspect + cjson + luassert
luaEnv3 = luaEnv2.withPackages (lp: [ lp.luassert ]);
wlib.types set documentation
wlib.types.subWrapperModuleWith
Like lib.types.submoduleWith but for wrapper modules!
Use this when you want any module (nixos and home manager included) to be able to accept other programs along with custom configurations.
The resulting config.optionname value will contain .config from the evaluated wrapper module, just like lib.types.submoduleWith
In other words, it will contain the same thing calling .apply returns.
This means you may grab the wrapped package from config.optionname.wrapper
It takes all the same arguments as lib.types.submoduleWith
wlib.types.subWrapperModuleWith = {
modules ? [],
specialArgs ? {},
shorthandOnlyDefinesConfig ? false,
description ? null,
class ? null
}:
In fact, it IS a submodule.
This function simply adds wlib.core to the list of modules you pass,
and both wlib and modulesPath (from wlib.modulesPath) to the specialArgs argument you pass.
To perform type-merging with this type, use lib.types.submodule or lib.types.submoduleWith
wlib.types.subWrapperModule
wlib.types.subWrapperModule = module: wlib.types.subWrapperModuleWith { modules = lib.toList module; };
i.e.
options.myopts.xplr = lib.mkOption {
type = wlib.types.subWrapperModule wlib.wrapperModules.xplr;
};
# and access config.myopts.xplr.wrapped and set settings and options within it.
wlib.types.specWith
Modified submoduleWith type for making options which are either an item, or a set with the item in it.
It will auto-normalize the values into the set form on merge,
so you can avoid custom normalization logic when using the config value associated with the option.
The dag and dal types are made using this type.
wlib.types.specWith =
{
modules,
specialArgs ? { },
class ? null,
description ? null,
mainField ? null,
dontConvertFunctions ? false,
}:
modules,specialArgs,class,descriptionare the same as forsubmoduleWith.mainField ? nullYou may specify your main field with this option.- If you don’t, it will detect this value based on the option you do not give a default value to in your base modules.
- You may only have 1 option without a default.
- Any nested options will be assumed to have defaults.
- If you have more than 1, and do not set
mainField, it will error, and if you do set it, conversion will fail. In that case a submodule type would be a better match.
dontConvertFunctions ? false:trueallows passing function-type submodules as specs. If yourdatafield’s type may contain a function, or is a submodule type itself, this should be left asfalse.- Setting
freeformTypeallows entries to have unchecked extra attributes. If your item is a set, and might contain your main field, you will want to avoid this to avoid false positives.
wlib.types.spec
wlib.types.spec = module: wlib.types.specWith { modules = lib.toList module; };
wlib.types.dalOf
A DAG LIST or (DAL) or dependency list of some inner type
Arguments:
elemType:type
Accepts a LIST of elements
The elements should be of type elemType
or sets of the type { data, name ? null, before ? [], after ? [] }
where the data field is of type elemType
If a name is not given, it cannot be targeted by other values.
Can be used in conjunction with wlib.dag.topoSort, wlib.dag.sortAndUnwrap, and wlib.dag.unwrapSort
Note, if the element type is a submodule then the name argument
will always be set to the string “data” since it picks up the
internal structure of the DAG values. To give access to the
“actual” attribute name a new submodule argument is provided with
the name dagName.
The config.optionname value from the associated option
will be normalized such that all items are DAG entries
If you wish to alter the type, you may provide different options
to wlib.dag.dalWith by updating this type wlib.types.dalOf // { strict = false; }
You can further modify the type with type merging!
Redefine the option with the type lib.types.listOf (wlib.types.spec ({ your module here }))
wlib.types.dagOf
A directed acyclic graph (attrset) of some inner type.
Arguments:
elemType:type
Accepts an attrset of elements
The elements should be of type elemType
or sets of the type { data, name ? null, before ? [], after ? [] }
where the data field is of type elemType
name defaults to the key in the set.
Can be used in conjunction with wlib.dag.topoSort, wlib.dag.sortAndUnwrap, and wlib.dag.unwrapSort
Note, if the element type is a submodule then the name argument
will always be set to the string “data” since it picks up the
internal structure of the DAG values. To give access to the
“actual” attribute name a new submodule argument is provided with
the name dagName.
The config.optionname value from the associated option
will be normalized such that all items are DAG entries
If you wish to alter the type, you may provide different options
to wlib.dag.dagWith by updating this type wlib.types.dagOf // { strict = false; }
You can further modify the type with type merging!
Redefine the option with the type lib.types.attrsOf (wlib.types.spec ({ your module here }))
wlib.types.seriesOf
This type functions like the lib.types.listOf type, but has reversed order across imports.
The individual lists assigned are unaffected.
This means, when you import a module, and it sets config.optionwiththistype,
it will append to the importing module’s definitions rather than prepending to them.
This type is sometimes very useful when you want multiple .wrap, .apply, .eval, and .extendModules
calls in series to apply to this option in a particular way.
This is because in that case with lib.types.listOf,
each successive call will place its new items BEFORE the last call.
In some cases, where the first item will win, e.g. lndir this makes sense, or is inconsequential.
In others, (for example, with the config.overrides field from the core module) you really want them to run in series. So you can use seriesOf!
wlib.types.dalWithEsc
same as dalOf except with an extra field esc-fn
esc-fn is to be null, or a function that returns a string
used by wlib.modules.makeWrapper
wlib.types.dagWithEsc
same as dagOf except with an extra field esc-fn
esc-fn is to be null, or a function that returns a string
used by wlib.modules.makeWrapper
wlib.types.withPackagesType
The kind of type you would provide to pkgs.lua.withPackages or pkgs.python3.withPackages
This type is a function from a set of packages to a list of packages.
If you set it in multiple files, it will merge the resulting lists according to normal module rules for a listOf package.
wlib.types.stringable
Type for a value that can be converted to string "${like_this}"
used by wlib.modules.makeWrapper
wlib.types.nonEmptyLine
A single-line, non-empty string
wlib.types.fixedList
Arguments:
length:int,elemType:type
It’s a list, but it rejects lists of the wrong length.
Still has regular list merge across multiple definitions, best used inside another list
wlib.types.wrapperFlags
Arguments:
length:int,
len: wlib.types.dalOf (wlib.types.fixedList len wlib.types.stringable)
wlib.types.wrapperFlag
DAL (list) of (stringable or list of stringable)
More flexible than wlib.types.wrapperFlags, allows single items, or lists of items of varied length
wlib.types.file
File type with content and path options
Arguments:
pkgs: nixpkgs instance
Fields:
content: File contents as stringpath: Derived path usingpkgs.writeText
wlib.types.attrsRecursive
Like lib.types.anything, but allows contained lists to also be merged
wlib.dag set documentation
wlib.dag.dagWith
Arguments:
-
settings:defaultNameFn ? ({ config, name, isDal, ... }@moduleArgs: if isDal then null else name): Function to compute the defaultnamefor entries. Recieves the submodule arguments.dataTypeFn?(elemType: { config, name, isDal, ... }@moduleArgs: elemType): Can be used if the type of thedatafield needs to depend upon the submodule arguments.- …other arguments for
wlib.types.specWith(modules,specialArgs, etc…) Passed through to configure submodules in the DAG entries.
-
elemType:typeThe type of the DAG entries’datafield. You can provide the type, OR an entry for each item. In the resultingconfig.optionnamevalue, all items are normalized into entries.
Notes:
dagWithaccepts an attrset as its first parameter (thesettings) beforeelemType.- To add extra type-checked fields, use the
modulesattribute, which is passed through towlib.types.specWith. The allowed dag fields will be automatically generated from the base set of modules passed. - The
config.optionnamevalue from the associated option will be normalized so that all items become valid DAG entries. - If
elemTypeis asubmoduleorspec, aparentNameargument will automatically be injected to access the actual attribute name.
wlib.dag.dalWith
Arguments:
-
settings:defaultNameFn ? ({ config, name, isDal, ... }@moduleArgs: if isDal then null else name): Function to compute the defaultnamefor entries. Recieves the submodule arguments.dataTypeFn?(elemType: { config, name, isDal, ... }@moduleArgs: elemType): Can be used if the type of thedatafield needs to depend upon the submodule arguments.- …other arguments for
wlib.types.specWith(modules,specialArgs, etc…) Passed through to configure submodules in the DAG entries.
-
elemType:typeThe type of the DAL entries’datafield. You can provide the type, OR an entry for each item. In the resultingconfig.optionnamevalue, all items are normalized into entries.
Notes:
dalWithaccepts an attrset as its first parameter (thesettings) beforeelemType.- To add extra type-checked fields, use the
modulesattribute, which is passed through towlib.types.specWith. The allowed dag fields will be automatically generated from the base set of modules passed. - The
config.optionnamevalue from the associated option will be normalized so that all items become valid DAG entries. - If
elemTypeis asubmoduleorspec, aparentNameargument will automatically be injected to access the actual attribute name.
wlib.dag.mkDagEntry
Arguments:
{
dataOptFn, # <- receives the submodule arguments. Returns a set for `lib.mkOption` (`internal = true` will be added unless you set it otherwise)
defaultNameFn ? { name, isDal, ... }@moduleArgs: if isDal then null else name,
isDal ? false, # <- added to `config._module.args`
}:
dataOptFn receives config, options, name, and isDal. Returns a set for lib.mkOption
Creates a module with a name, data, before, and after field,
which can be passed to wlib.types.specWith or wlib.types.spec,
to create a spec type which can be used with all the wlib.dag functions.
wlib.dag.dagNameModule
If, when constructing your own DAG type with mkDagEntry, your data field accepts submodules, you should also supply this module to specWith
in order to set config.data._module.args.dagName.
You would do this because the name argument of that submodule will receive the field it was in,
not the one from the parent attrsOf type.
If you use dagWith or dalWith, this is done for you for submodule and spec.
wlib.dag.topoSort
Takes an attribute set or list containing attrsets with (optional)
name, before and after fields.
It then sorts them into a topologically sorted list of entries.
It does not perform any normalization of the entries themselves.
Internally this function uses the toposort function in
<nixpkgs/lib/lists.nix> and it returns the same thing.
It returns an object which is like a “result”
Specifically, the result on success is
{ result = [ { name = ?; data = ?; … } … ] }
For example
nix-repl> topoSort {
a = entryAnywhere "1";
b = entryAfter [ "a" "c" ] "2";
c = entryBefore [ "d" ] "3";
d = entryBefore [ "e" ] "4";
e = entryAnywhere "5";
} == {
result = [
{ data = "1"; name = "a"; after = [ ]; before = [ ]; }
{ data = "3"; name = "c"; after = [ ]; before = [ "d" ]; }
{ data = "2"; name = "b"; after = [ "a" "c" ]; before = [ ]; }
{ data = "4"; name = "d"; after = [ ]; before = [ "e" ]; }
{ data = "5"; name = "e"; after = [ ]; before = [ ]; }
];
}
true
And the result on error is
{
cycle = [ { after = ?; name = ?; data = ? } … ];
loops = [ { after = ?; name = ?; data = ? } … ];
}
For example
nix-repl> topoSort {
a = entryAnywhere "1";
b = entryAfter [ "a" "c" ] "2";
c = entryAfter [ "d" ] "3";
d = entryAfter [ "b" ] "4";
e = entryAnywhere "5";
} == {
cycle = [
{ data = "2"; name = "b"; after = [ "a" "c" ]; before = [ ]; }
{ data = "3"; name = "c"; after = [ "d" ]; before = [ ]; }
{ data = "4"; name = "d"; after = [ "b" ]; before = [ ]; }
];
loops = [
{ data = "2"; name = "b"; after = [ "a" "c" ]; before = [ ]; }
];
}
true
dag-
Function argument
wlib.dag.unwrapSort
Convenience function for resolving a DAG or DAL and getting the result in a sorted list of DAG entries
wlib.dag.unwrapSort "name_for_error" { a = { before = [ "b" ]; }; b = { data = 1; }; }
The result is a sorted DAL, the result field from calling wlib.dag.topoSort
Accepts the same types in its dag argument as wlib.dag.topoSort.
But it returns the resulting list directly, and throws an error message if there is a cycle
wlib.dag.sortAndUnwrap
Same as unwrapSort but its argument is a set and it optionally accepts a function to map over the result
Arguments:
{
dag,
name ? "DAG", # for error message
mapIfOk ? null,
}
wlib.dag.dagToDal
converts a DAG to a DAL
Accepts the same types as wlib.dag.topoSort.
It is the normalization function used by topoSort
when the argument is not a list prior to sorting the list.
wlib.dag.isEntry
Determines whether a value is a valid DAG entry (allows extra values)
Will return true if the item meets the following criteria:
Has a data field. If it has a name field that field is a string. If it has a before or after field that field is a list of strings.
It allows entries to have extra values not mentioned above.
wlib.dag.isDag
determines whether a value is of the attrset type and all values meet the criteria of wlib.dag.isEntry
Allows entries to have extra values
wlib.dag.isDal
determines whether a value is of the list type and all values meet the criteria of wlib.dag.isEntry
wlib.dag.lmap
Applies a function to each element of the given DAL.
Requires values to meet the criteria of wlib.dag.isEntry
wlib.dag.gmap
Applies a function to each element of the given DAG.
Requires values to meet the criteria of wlib.dag.isEntry
wlib.dag.mapDagToDal
wlib.dag.gmap but returns the result as a DAL
Requires values to meet the criteria of wlib.dag.isEntry
wlib.dag.entryBetween
Creates a DAG entry with specified before and after dependencies.
wlib.dag.entryAnywhere
Create a DAG entry with no particular dependency information.
wlib.dag.entryAfter
Convenience function to create a DAG entry that should come after certain nodes.
wlib.dag.entryBefore
Convenience function to create a DAG entry that should come before certain nodes.
wlib.dag.entriesBetween
Given a list of entries, this function places them in order within the DAG. Each entry is labeled “${tag}-${entry index}” and other DAG entries can be added with ‘before’ or ‘after’ referring these indexed entries.
The entries as a whole can be given a relation to other DAG nodes. All generated nodes are then placed before or after those dependencies.
wlib.dag.entriesAnywhere
Convenience function for creating multiple entries without specific dependencies.
wlib.dag.entriesAfter
Convenience function for creating multiple entries that must be after another entry
wlib.dag.entriesBefore
Convenience function for creating multiple entries that must be before another entry
Core (builtin) Options set
lib/core.nix
This module is made possible by: birdee
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"hello"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/hello"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation hello-2.12.2>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.modules.default
modules/symlinkScript
This module is made possible by: birdee
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation hello-2.12.2>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
The makeWrapper library:
Should you ever need to redefine config.wrapperFunction, or use these options somewhere else,
this module doubles as a library for doing so!
makeWrapper = import wlib.modules.makeWrapper;
If you import it like shown, you gain access to some values.
First, you may modify the module itself.
For this it offers:
exclude_wrapper = true; to stop it from setting config.wrapperFunction
wrapperFunction = ...; to override the default config.wrapperFunction that it sets instead of excluding it.
exclude_meta = true; to stop it from setting any values in config.meta
excluded_options = { ... }; where you may include optionname = true
in order to not define that option.
_file and key: _file changes the value set for the modules imported when you import this module. key is set on the main one if not null.
In order to change these values, you change them in the set before importing the module like so:
imports = [ (import wlib.modules.makeWrapper // { excluded_options.wrapperVariants = true; }) ];
It also offers 4 functions for using those options to generate build instructions for a wrapper
wrapAll: generates build instructions for the main target and all variantswrapMain: generates build instructions for the main targetwrapVariants: generates build instructions for all variants but not the main targetwrapVariant: generates build instructions for a single variant
All 4 of them return a string that can be added to the derivation definition to build the specified wrappers.
The first 3, wrapAll, wrapMain, and wrapVariants, are used like this:
(import wlib.modules.makeWrapper).wrapAll {
inherit config wlib;
inherit (pkgs) callPackage; # or inherit pkgs;
};
The 4th, wrapVariant, has an extra name argument:
(import wlib.modules.makeWrapper).wrapVariant {
inherit config wlib;
inherit (pkgs) callPackage; # or inherit pkgs;
name = "attribute";
};
Where attribute is an attribute of the config.wrapperVariants set
Other than whatever options from the wlib.modules.makeWrapper module
are defined in the config variable passed,
each one relies on config containing binName, package, and exePath.
If config.exePath is not a string or is an empty string,
config.package will be the full path wrapped.
Otherwise, it will wrap "${config.package}/${config.binName}.
If config.binName or config.package are not provided it will return an empty string for that target.
In addition, if a variant has enable set to false, it will also not be included in the returned string.
wlib.modules
In this subsection are what we will call “helper modules”.
They are just regular modules. The distinction is that they do not set config.package
Instead, their purpose is to create convenience options for you to use to define your own wrappers!
The example you will become most familiar with are the helper modules imported by wlib.modules.default
wlib.modules.default gets its options by importing 2 other modules, wlib.modules.symlinkScript and wlib.modules.makeWrapper.
But you could choose to have modules that have different abilities!
For example, someone may want to make a set of convenience options for wrapping your program with bubblewrap or some other sandboxing tool instead!
They could make a module for that, and submit it here for everyone to enjoy!
wlib.modules.makeWrapper
modules/makeWrapper
This module is made possible by: birdee
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation hello-2.12.2>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
The makeWrapper library:
Should you ever need to redefine config.wrapperFunction, or use these options somewhere else,
this module doubles as a library for doing so!
makeWrapper = import wlib.modules.makeWrapper;
If you import it like shown, you gain access to some values.
First, you may modify the module itself.
For this it offers:
exclude_wrapper = true; to stop it from setting config.wrapperFunction
wrapperFunction = ...; to override the default config.wrapperFunction that it sets instead of excluding it.
exclude_meta = true; to stop it from setting any values in config.meta
excluded_options = { ... }; where you may include optionname = true
in order to not define that option.
_file and key: _file changes the value set for the modules imported when you import this module. key is set on the main one if not null.
In order to change these values, you change them in the set before importing the module like so:
imports = [ (import wlib.modules.makeWrapper // { excluded_options.wrapperVariants = true; }) ];
It also offers 4 functions for using those options to generate build instructions for a wrapper
wrapAll: generates build instructions for the main target and all variantswrapMain: generates build instructions for the main targetwrapVariants: generates build instructions for all variants but not the main targetwrapVariant: generates build instructions for a single variant
All 4 of them return a string that can be added to the derivation definition to build the specified wrappers.
The first 3, wrapAll, wrapMain, and wrapVariants, are used like this:
(import wlib.modules.makeWrapper).wrapAll {
inherit config wlib;
inherit (pkgs) callPackage; # or inherit pkgs;
};
The 4th, wrapVariant, has an extra name argument:
(import wlib.modules.makeWrapper).wrapVariant {
inherit config wlib;
inherit (pkgs) callPackage; # or inherit pkgs;
name = "attribute";
};
Where attribute is an attribute of the config.wrapperVariants set
Other than whatever options from the wlib.modules.makeWrapper module
are defined in the config variable passed,
each one relies on config containing binName, package, and exePath.
If config.exePath is not a string or is an empty string,
config.package will be the full path wrapped.
Otherwise, it will wrap "${config.package}/${config.binName}.
If config.binName or config.package are not provided it will return an empty string for that target.
In addition, if a variant has enable set to false, it will also not be included in the returned string.
wlib.modules.symlinkScript
modules/symlinkScript
This module is made possible by: birdee
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
wlib.wrapperModules
wrapper modules are modules which set config.package and define convenience options for wrapping that package with a configuration.
They are specific to that program, and make configuring programs in an ad-hoc way stress-free!
They include shortlist options for common configuration settings, and/or for providing a config file to use.
wlib.wrapperModules contains paths to these wrapper modules.
The flake also exports wrapper modules that have been partially evaluated for convenience.
This allows you to do something like inputs.nix-wrapper-modules.wrappers.tmux.wrap { inherit pkgs; prefix = "C-Space"; }, to build a package with a particular configuration quickly!
You can then export that package, and somebody else could call .wrap on it as well to change it again!
wlib.wrapperModules.alacritty
wrapperModules/a/alacritty
This module is made possible by: birdee
settings
Configuration of alacritty.
See {manpage}alacritty(5) or https://alacritty.org/config-alacritty.html
Type: TOML value
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config-file" = {
after = [ ];
before = [ ];
data = <derivation alacritty.toml>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation alacritty-0.16.1>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"alacritty"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/alacritty"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"terminfo"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation alacritty-0.16.1>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.atool
wrapperModules/a/atool
This module is made possible by: Jomar Milan
settings
Configuration options of atool via the –option flag.
See {manpage}atool(1)
Type: attribute set of (string or boolean)
Default:
{ }
Declared by:
tools.enable
Enable managing which tool paths atool will use.
Type: boolean
Default:
true
Declared by:
tools.paths."7z"
Path to the 7z executable.
Type: string
Default:
"/nix/store/9zy0g1djayzh25g8b1y7p9p928ic28cs-p7zip-17.06/bin/7z"
Declared by:
tools.paths.arj
Path to the arj executable.
Type: string
Default:
"/nix/store/2zngbid4mrfhiwc9a7xqmvbzr603zm38-arj-3.10.22/bin/arj"
Declared by:
tools.paths.bzip2
Path to the bzip2 execeutable.
Type: string
Default:
"/nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin/bin/bzip2"
Declared by:
tools.paths.cabextract
Path to the cabextract executable.
Type: string
Default:
"/nix/store/qnw13h7mjl897aqw817paj25fclmvhsp-cabextract-1.11/bin/cabextract"
Declared by:
tools.paths.cpio
Path to the cpio executable.
Type: string
Default:
"/nix/store/bnf1y2hy2151xj0jg3v6gjyp1mqwl1cy-cpio-2.15/bin/cpio"
Declared by:
tools.paths.dpkg_deb
Path to the dpkg-deb executable.
Type: string
Default:
"/nix/store/kls9dgmmdrvnxm07zyshxm4ppw0jg2h7-dpkg-1.22.21/bin/dpkg-deb"
Declared by:
tools.paths.gzip
Path to the gzip execeutable.
Type: string
Default:
"/nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14/bin/gzip"
Declared by:
tools.paths.lrzip
Path to the lrzip executable.
Type: string
Default:
"/nix/store/rmgdsmnwi453a98k6jrlm486a0jzc5vp-lrzip-0.651/bin/lrzip"
Declared by:
tools.paths.lzma
Path to the lzma execeutable.
Type: string
Default:
"/nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin/bin/lzma"
Declared by:
tools.paths.lzop
Path to the lzop executable.
Type: string
Default:
"/nix/store/gd6dhvwn3k4iqzhdsf9mgfxv50ya4dyl-lzop-1.04/bin/lzop"
Declared by:
tools.paths.rar
Path to the rar executable.
Type: string
Default:
"rar"
Declared by:
tools.paths.rpm
Path to the rpm executable.
Type: string
Default:
"/nix/store/bqrjjqpcsswskyv4x9swrhhvkz4m54bg-rpm-4.20.1/bin/rpm"
Declared by:
tools.paths.rpm2cpio
Path to the rpm2cpio executable.
Type: string
Default:
"/nix/store/bqrjjqpcsswskyv4x9swrhhvkz4m54bg-rpm-4.20.1/bin/rpm2cpio"
Declared by:
tools.paths.rzip
Path to the rzip executable.
Type: string
Default:
"/nix/store/gdh2fq9ikas0320ki94f6hr5qadf5vlc-rzip-2.1/bin/rzip"
Declared by:
tools.paths.tar
Path to the tar executable.
Type: string
Default:
"/nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35/bin/tar"
Declared by:
tools.paths.unrar
Path to the lzma execeutable.
Type: string
Default:
"unrar"
Declared by:
tools.paths.unzip
Path to the unzip execeutable.
Type: string
Default:
"/nix/store/d8dikfh0z22zmqxjgj0sw6v8sfnfv0nv-unzip-6.0/bin/unzip"
Declared by:
tools.paths.zip
Path to the zip execeutable.
Type: string
Default:
"/nix/store/gmnyjhnic4kcg3k33lifhpsm4v0zxhrb-zip-3.0/bin/zip"
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--option" = {
after = [ ];
before = [ ];
data = [
"path_7z=/nix/store/9zy0g1djayzh25g8b1y7p9p928ic28cs-p7zip-17.06/bin/7z"
"path_arj=/nix/store/2zngbid4mrfhiwc9a7xqmvbzr603zm38-arj-3.10.22/bin/arj"
"path_bzip2=/nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin/bin/bzip2"
"path_cabextract=/nix/store/qnw13h7mjl897aqw817paj25fclmvhsp-cabextract-1.11/bin/cabextract"
"path_cpio=/nix/store/bnf1y2hy2151xj0jg3v6gjyp1mqwl1cy-cpio-2.15/bin/cpio"
"path_dpkg_deb=/nix/store/kls9dgmmdrvnxm07zyshxm4ppw0jg2h7-dpkg-1.22.21/bin/dpkg-deb"
"path_gzip=/nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14/bin/gzip"
"path_lrzip=/nix/store/rmgdsmnwi453a98k6jrlm486a0jzc5vp-lrzip-0.651/bin/lrzip"
"path_lzma=/nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin/bin/lzma"
"path_lzop=/nix/store/gd6dhvwn3k4iqzhdsf9mgfxv50ya4dyl-lzop-1.04/bin/lzop"
"path_rar=rar"
"path_rpm=/nix/store/bqrjjqpcsswskyv4x9swrhhvkz4m54bg-rpm-4.20.1/bin/rpm"
"path_rpm2cpio=/nix/store/bqrjjqpcsswskyv4x9swrhhvkz4m54bg-rpm-4.20.1/bin/rpm2cpio"
"path_rzip=/nix/store/gdh2fq9ikas0320ki94f6hr5qadf5vlc-rzip-2.1/bin/rzip"
"path_tar=/nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35/bin/tar"
"path_unrar=unrar"
"path_unzip=/nix/store/d8dikfh0z22zmqxjgj0sw6v8sfnfv0nv-unzip-6.0/bin/unzip"
"path_zip=/nix/store/gmnyjhnic4kcg3k33lifhpsm4v0zxhrb-zip-3.0/bin/zip"
];
esc-fn = null;
name = null;
sep = "=";
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation atool-0.39.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"atool"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/atool"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation atool-0.39.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.btop
wrapperModules/b/btop
This module is made possible by: Ameer Taweel
settings
Options to add to {file}btop.conf file.
See https://github.com/aristocratos/btop#configurability
for options.
Type: attribute set of (boolean or floating point number or signed integer or string)
Default:
{ }
Example:
{
color_theme = "ayu";
vim_keys = true;
}
Declared by:
themes
Custom Btop themes.
Type: lazy attribute set of (absolute path or strings concatenated with “\n”)
Default:
{ }
Example:
{
my-theme = ''
theme[main_bg]="#282a36"
theme[main_fg]="#f8f8f2"
theme[title]="#f8f8f2"
theme[hi_fg]="#6272a4"
theme[selected_bg]="#ff79c6"
theme[selected_fg]="#f8f8f2"
theme[inactive_fg]="#44475a"
theme[graph_text]="#f8f8f2"
theme[meter_bg]="#44475a"
theme[proc_misc]="#bd93f9"
theme[cpu_box]="#bd93f9"
theme[mem_box]="#50fa7b"
theme[net_box]="#ff5555"
theme[proc_box]="#8be9fd"
theme[div_line]="#44475a"
theme[temp_start]="#bd93f9"
theme[temp_mid]="#ff79c6"
theme[temp_end]="#ff33a8"
theme[cpu_start]="#bd93f9"
theme[cpu_mid]="#8be9fd"
theme[cpu_end]="#50fa7b"
theme[free_start]="#ffa6d9"
theme[free_mid]="#ff79c6"
theme[free_end]="#ff33a8"
theme[cached_start]="#b1f0fd"
theme[cached_mid]="#8be9fd"
theme[cached_end]="#26d7fd"
theme[available_start]="#ffd4a6"
theme[available_mid]="#ffb86c"
theme[available_end]="#ff9c33"
theme[used_start]="#96faaf"
theme[used_mid]="#50fa7b"
theme[used_end]="#0dfa49"
theme[download_start]="#bd93f9"
theme[download_mid]="#50fa7b"
theme[download_end]="#8be9fd"
theme[upload_start]="#8c42ab"
theme[upload_mid]="#ff79c6"
theme[upload_end]="#ff33a8"
theme[process_start]="#50fa7b"
theme[process_mid]="#59b690"
theme[process_end]="#6272a4"
'';
}
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = <derivation btop.conf>;
esc-fn = null;
name = null;
sep = null;
};
"--themes-dir" = {
after = [ ];
before = [ ];
data = "/nix/store/bfrmv3i2gwa6pbjn5sizgw787nz2m8d5-mdbook-0.5.2/themes";
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation btop-1.4.6>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"btop"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/btop"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation btop-1.4.6>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.claude-code
wrapperModules/c/claude-code
This module is made possible by: Vinny Meller
agents
Custom agents to add to Claude Code.
See https://code.claude.com/docs/en/sub-agents
Type: JSON value
Default:
{ }
Example:
{
code-reviewer = {
description = "Expert code reviewer. Use proactively after code changes.";
model = "sonnet";
prompt = "You are a senior code reviewer. Focus on code quality, security, and best practices.";
tools = [
"Read"
"Grep"
"Glob"
"Bash"
];
};
}
Declared by:
mcpConfig
MCP Server configuration
Exclude the top-level mcpServers key from the configuration as it is automatically handled.
See https://code.claude.com/docs/en/mcp
Type: JSON value
Default:
{ }
Example:
{
nixos = {
command = "/nix/store/24vn7vyds9lx3r6v8869vqwfd9354l5v-mcp-nixos-2.1.1/bin/mcp-nixos";
type = "stdio";
};
}
Declared by:
pluginDirs
Additional directories to search for Claude Code plugins, in addition to the standard locations.
This can be used to either load arbitrary directories of plugins, or include non-flake plugin repos managed via Nix.
See https://code.claude.com/docs/en/plugins
Type: list of str|path|drv
Default:
[ ]
Example:
[
"~/.custom-claude-plugins"
"\${inputs.claude-plugins-official}/plugins/ralph-loop"
]
Declared by:
settings
Claude Code settings
These settings will override local, project, and user scoped settings.
See https://code.claude.com/docs/en/settings
Type: JSON value
Default:
{ }
Example:
{
includeCoAuthoredBy = false;
permissions = {
deny = [
"Bash(sudo:*)"
"Bash(rm -rf:*)"
];
};
}
Declared by:
strictMcpConfig
Whether to enable the --strict-mcp-config flag for Claude Code.
When enabled, Claude will only use the MCP servers provided by the mcpConfig option.
If disabled, Claude may use MCP servers defined elsewhere (e.g., user or project scoped configurations).
Type: boolean
Default:
false
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = {
after = [ ];
before = [ ];
data = "1";
esc-fn = null;
name = null;
};
DISABLE_AUTOUPDATER = {
after = [ ];
before = [ ];
data = "1";
esc-fn = null;
name = null;
};
DISABLE_INSTALLATION_CHECKS = {
after = [ ];
before = [ ];
data = "1";
esc-fn = null;
name = null;
};
DISABLE_NON_ESSENTIAL_MODEL_CALLS = {
after = [ ];
before = [ ];
data = "1";
esc-fn = null;
name = null;
};
DISABLE_TELEMETRY = {
after = [ ];
before = [ ];
data = "1";
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--agents" = {
after = [ ];
before = [ ];
data = "{}";
esc-fn = null;
name = null;
sep = null;
};
"--mcp-config" = {
after = [ ];
before = [ ];
data = <derivation claude-mcp-config.json>;
esc-fn = null;
name = null;
sep = null;
};
"--plugin-dir" = {
after = [ ];
before = [ ];
data = [ ];
esc-fn = null;
name = null;
sep = null;
};
"--settings" = {
after = [ ];
before = [ ];
data = <derivation claude-settings.json>;
esc-fn = null;
name = null;
sep = null;
};
"--strict-mcp-config" = {
after = [ ];
before = [ ];
data = false;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation claude-code-2.1.34>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[
{
after = [ ];
before = [ ];
data = "DEV";
esc-fn = null;
name = "[definition 1-entry 1]";
}
{
after = [ ];
before = [ ];
data = "ANTHROPIC_API_KEY";
esc-fn = null;
name = "[definition 1-entry 2]";
}
]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"claude"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/claude"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation claude-code-2.1.34>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.foot
wrapperModules/f/foot
This module is made possible by: birdee
settings
Configuration of foot terminal.
See {manpage}foot.ini(5)
Type: attribute set of section of an INI file (attrs of INI atom (null, bool, int, float or string))
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = <derivation foot.ini>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation foot-1.25.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"foot"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/foot"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"terminfo"
"themes"
"debug"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation foot-1.25.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.fuzzel
wrapperModules/f/fuzzel
This module is made possible by: birdee
settings
Configuration of fuzzel.
See {manpage}fuzzel.ini(5)
Type: attribute set of section of an INI file (attrs of INI atom (null, bool, int, float or string))
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
"="
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = <derivation fuzzel.ini>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation fuzzel-1.14.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"fuzzel"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/fuzzel"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation fuzzel-1.14.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.git
wrapperModules/g/git
This module is made possible by: birdee
Nix uses git for all sorts of things. Including fetching flakes!
So if you put this one in an overlay, name it something other than pkgs.git!
Otherwise you will probably get infinite recursion.
The vast majority of other packages do not have this issue. And,
due to the passthrough of .override and .overrideAttrs,
most other packages are safe to replace with their wrapped counterpart in overlays directly.
configFile
Generated git configuration file.
Type: submodule
Default:
{
path = <derivation gitconfig>;
}
Declared by:
configFile.content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
configFile.path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
settings
Git configuration settings.
See {manpage}git-config(1) for available options.
Type: attribute set of attribute set of (INI atom (null, bool, int, float or string) or attribute set of (INI atom (null, bool, int, float or string)))
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
GIT_CONFIG_GLOBAL = {
after = [ ];
before = [ ];
data = <derivation gitconfig>;
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation git-2.52.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"git"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/git"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"doc"
"debug"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation git-2.52.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.helix
wrapperModules/h/helix
This module is made possible by: birdee
extraSettings
Extra lines appended to the config file. This can be used to maintain order for settings.
Type: strings concatenated with “\n”
Default:
""
Declared by:
ignores
List of paths to be ignored by the file-picker. The format is the same as in .gitignore.
Type: list of non-empty string
Default:
[ ]
Declared by:
languages
Language specific settings See https://docs.helix-editor.com/languages.html
Type: TOML value
Default:
{ }
Declared by:
settings
General settings See https://docs.helix-editor.com/configuration.html
Type: TOML value
Default:
{ }
Declared by:
themes
Themes to add to config. See https://docs.helix-editor.com/themes.html
Type: attribute set of (TOML value or strings concatenated with “\n”)
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
XDG_CONFIG_HOME = {
after = [ ];
before = [ ];
data = "/nix/store/l41qq7gpj9rjf6zckrcpmak61lk3bmh5-helix-merged-config";
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation helix-25.07.1>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"hx"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/hx"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"doc"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation helix-25.07.1>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.jujutsu
wrapperModules/j/jujutsu
This module is made possible by: birdee
settings
Configuration for jujutsu. See https://jj-vcs.github.io/jj/latest/config/
Type: TOML value
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
JJ_CONFIG = {
after = [ ];
before = [ ];
data = "/nix/store/4zi07zq78yhgg7jx2kiwx3i9j03r90gv-jujutsu.toml";
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation jujutsu-0.38.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"jj"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/jj"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation jujutsu-0.38.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.mako
wrapperModules/m/mako
This module is made possible by: birdee
"--config"
Path to the generated Mako configuration file.
The file is built automatically from the settings option using the
iniWithGlobalSection formatter. You can override this path to use a
custom configuration file instead.
Example: –config=/etc/mako/config
Type: submodule
Default:
{
path = <derivation mako-settings>;
}
Declared by:
"--config".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"--config".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
settings
Configuration settings for mako. Can include both global settings and sections. All available options can be found here: https://github.com/emersion/mako/blob/master/doc/mako.5.scd.
Type: attribute set of (INI atom (null, bool, int, float or string) or attribute set of (INI atom (null, bool, int, float or string)))
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
"="
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = <derivation mako-settings>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation mako-1.10.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"mako"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/mako"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation mako-1.10.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.mdbook
wrapperModules/m/mdbook
This module is made possible by: birdee
This module makes use of wrapperVariants to make a script for each of the books you define.
If you make an entry in the books attribute set, you will get a binary of that name,
which as its first argument takes the output directory to generate to (or a default if not provided).
As each one already has its book directory specified and -d option set to the first argument or a default,
you only have access to the other flags on these items at runtime.
To achieve greater runtime control, run the main executable with one of the generated books within the derivation
as input yourself, either at runtime, or within the module via ${placeholder "out"}/${config.book-out-dir}/${name}
Within the module, there is an option called mainBook to REPLACE the main executable with a symlink to the desired book generation script.
For more fine-tuned control, you should instead give it the path to the book yourself as demonstrated above.
book-out-dir
The books are generated to:
${placeholder "out"}/${config.book-out-dir}/${name}
Type: (read-only) string
Default:
"mdbook-book-dir"
Declared by:
books
A set of books to generate along with the mdbook derivation.
It will also create a build script for each one.
That build script will be a wrapped mdbook executable.
It will run something like the following:
mdbook build -d $firstArg "${otherArgs[@]}" <generated-book-subdir>
You could modify it further with the wrapperVariants attribute of the same name,
for example to add a -o flag.
Or use it as the main command for running via nix run in a build pipeline using mainBook = "this_book";
Type: attribute set of (submodule)
Default:
{ }
Declared by:
books.<name>.book
Values for the book.toml file for this book.
Reference: rust-lang.github.io/mdBook/format/configuration/general.html
Any null values will be as if not declared.
Type: open submodule of (nullable TOML value)
Default:
{ }
Declared by:
books.<name>.book.book
The book table of the book.toml file.
Reference: rust-lang.github.io/mdBook/format/configuration/general.html#general-metadata
Type: open submodule of (nullable TOML value)
Declared by:
books.<name>.book.book.authors
The author(s) of the book
Type: null or (list of string)
Default:
null
Declared by:
books.<name>.book.book.description
A description for the book, which is added as meta information in the html <head> of each page
Type: null or string
Default:
null
Declared by:
books.<name>.book.book.language
The main language of the book, which is used as a
language attribute <html lang="en"> for example.
This is also used to derive the direction of text (RTL, LTR) within the book.
Type: null or non-empty string
Default:
null
Declared by:
books.<name>.book.book.src
By default, the source directory is found in the directory named src directly under the root folder.
Type: non-empty string
Default:
"src"
Declared by:
books.<name>.book.book.text-direction
The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL).
Possible values: ltr, rtl.
When not specified, the text direction is derived from the book’s language attribute.
Type: null or non-empty string
Default:
null
Declared by:
books.<name>.book.book.title
The title of the book
Type: null or string
Default:
null
Declared by:
books.<name>.defaultOutLocation
The book outputs take the target directory to generate to as their first argument.
This sets the default output directory for this book if the first argument is not supplied.
Type: string
Default:
"_site"
Declared by:
books.<name>.enable
Whether to enable the book ‹name›.
Type: boolean
Default:
true
Example:
true
Declared by:
books.<name>.generated-book-subdir
The directory within the wrapped derivation that contains the generated markdown for the book.
${placeholder "out"}/${config.books.<name>.generated-book-subdir} is the root of this book.
Type: (read-only) string
Default:
"mdbook-book-dir/‹name›"
Declared by:
books.<name>.summary
Builds your summary, and your book!
A list of specs, with the main field, data,
representing the type of the item.
Accepts prefix, suffix, title, numbered, draft, separator
For info on what those are:
rust-lang.github.io/mdBook/format/summary
In addition, it accepts name, subchapters, src, and path.
These values are processed differently depending on the type of item.
path refers to the output path src will be linked to.
It is relative to the book root dir.
name is the visible part of the summary item, if it displays text.
You can also sort based on name, before, and after like the other DAL options.
It will sort within each chapter list if any orderings were specified.
subchapters are processed recursively, and the depth represents the indentation of the summary item.
Type:
list of spec with main field: data of (one of “prefix”, “suffix”, “title”, “numbered”, “draft”, “separator”)
Default:
[ ]
Declared by:
books.<name>.summary.*.after
Ensure this item appears after the named entries in this list
Type: list of string
Default:
[ ]
Declared by:
books.<name>.summary.*.before
Ensure this item appears before the named entries in this list
Type: list of string
Default:
[ ]
Declared by:
books.<name>.summary.*.build
If extra processing is required to generate a source file for this item, you may specify extra commands to run before the wrapper links it into place here.
Type: strings concatenated with “\n”
Default:
""
Declared by:
books.<name>.summary.*.data
Identifies the kind of summary item.
This determines how the item is rendered in SUMMARY.md and which additional fields are required or meaningful.
Valid values are:
title — A section heading in the summary.
separator — A horizontal rule (—) separating sections. (can be defined simply as the string “separator” in the list unless you want to sort on them)
prefix — A link rendered before the main numbered chapters.
suffix — A link rendered after the main numbered chapters.
numbered — A standard numbered chapter entry.
draft — A chapter entry without a target path.
Rendering behavior and required fields depend on this value.
Type: one of “prefix”, “suffix”, “title”, “numbered”, “draft”, “separator”
Declared by:
books.<name>.summary.*.name
The name of the summary item. Usually rendered as the text of the item.
Can also be used as a sorting target by before and after fields of other items.
Type: null or string
Default:
null
Declared by:
books.<name>.summary.*.path
The relative output path of the item within the book directory.
Type: null or non-empty line
Default:
null
Declared by:
books.<name>.summary.*.src
If this item is of a type which accepts a source file,
this file will be linked to the location indicated by the path option.
Type: null or str|path|drv
Default:
null
Declared by:
books.<name>.summary.*.subchapters
The same options as this level of the summary, however the items within will be indented 1 level further.
Type:
list of spec with main field: data of (one of “prefix”, “suffix”, “title”, “numbered”, “draft”, “separator”)
Default:
[ ]
Declared by:
mainBook
If not null, replace the main package with a link to the generator script for that book
Type: null or non-empty line
Default:
null
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation mdbook-0.5.2>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"mdbook"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/mdbook"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation mdbook-0.5.2>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.mpv
wrapperModules/m/mpv
This module is made possible by: birdee
"mpv.conf"
The main MPV configuration file.
Provide .content to inline configuration options or .path to reference an existing mpv.conf.
This file controls playback behavior, default options, video filters, and output settings.
It is included by MPV using the --include flag.
Type: submodule
Default:
{
content = "";
}
Declared by:
"mpv.conf".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"mpv.conf".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
"mpv.input"
The MPV input configuration file.
Provide .content to inline bindings or .path to use an existing input.conf.
This file defines custom key bindings and command mappings.
It is passed to MPV using --input-conf.
Type: submodule
Default:
{
content = "";
}
Declared by:
"mpv.input".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"mpv.input".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
scripts
A list of MPV user scripts to include via package override.
Each entry should be a derivation providing a Lua script or plugin
compatible with MPV’s scripts/ directory.
These are appended to MPV’s build with pkgs.mpv.override.
Type: list of package
Default:
[ ]
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
"="
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--include" = {
after = [ ];
before = [ ];
data = <derivation mpv.conf>;
esc-fn = null;
name = null;
sep = null;
};
"--input-conf" = {
after = [ ];
before = [ ];
data = <derivation mpv.input>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation mpv-with-scripts-0.41.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"mpv"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/mpv"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation mpv-with-scripts-0.41.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.neovim
wrapperModules/n/neovim
This module is made possible by: birdee
Please see the template for an introductory example usage!
To initialize it, run nix flake init -t github:BirdeeHub/nix-wrapper-modules#neovim
If you are using zsh, you may need to escape the # character with a backslash.
The first thing to notice is config.settings.config_directory
Set it to an in-store, out-of-store, or lib.generators.mkLuaInline value!
It will be loaded just like a normal neovim configuration directory.
Plugins are provided via the config.specs option.
It takes a set of plugins, or a set of lists of plugins.
Each item that accepts a plugin may also be a spec with the plugin as its .data field,
which may optionally be customized by config.specMods and then further processed by config.specCollect (not too hard) and config.specMaps (advanced).
The spec forms offer the ability to provide plugins, configuration (in lua, vimscript, or fennel),
along with automatically translated lua values from nix in a finely controlled order.
A plugin may be an in-store or out-of-store path, but may not be an inline lua value.
Optionally supports the ability to avoid path collisions when installing multiple configured neovim packages!
You may do this via a combination of config.binName and config.settings.dont_link options.
This module provides an info plugin you can access in lua to get metadata about your nix install, as well as ad-hoc values you pass.
This module fully supports remote plugin hosts.
By the same mechanism, it also allows arbitrary other items to be bundled into the context of your neovim derivation, such as neovide,
via an option which accepts wrapper modules for maximum flexibility.
Please also check out the Tips and Tricks section for more information!
Options:
hosts
This option takes a set of wrapper modules.
Neovim has “remote plugin hosts” which allow plugins in other languages.
You can wrap such a host and pass them here.
The resulting wrapped package will also be added to the PATH alongside nvim
In fact, some defaults have been provided!
You can hosts.python3.nvim-host.enable = true;
and you can do the same with node and ruby
You can also wrap things that are not remote plugin hosts.
For example neovide! This allows you to keep the configuration for these in sync
You can also hosts.neovide.nvim-host.enable = true;
Each wrapper module in the set is given a nvim-host option, and evaluated,
with the result being accesible via config.hosts.<name>.<wrapper, nvim-host, binName, etc...>
the nvim-host option provides all the options of the wlib.modules.makeWrapper module again.
However these options are evaluated in the scope of the neovim wrapper, not the host wrapper.
In addition to the wlib.modules.makeWrapper options, it also adds the following options, which control how the host is added to neovim:
nvim-host.enable,
nvim-host.package,
nvim-host.var_path,
nvim-host.enabled_variable,
nvim-host.disabled_variable
nvim-host.dontWrap
This allows you to do things like
hosts.neovide.nvim-host.flags."--neovim-bin" = "${placeholder "out"}/bin/${config.binName}";
If you do hosts.neovide.nvim-host.enable = true; it will do that for you.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
hosts.<name>.nvim-host
Gives access to the full wlib.modules.makeWrapper options,
but ran in the context of the nvim host, not this sub wrapper module.
Also adds the following options, which control how the host is added to neovim:
nvim-host.enable,
nvim-host.package,
nvim-host.var_path,
nvim-host.enabled_variable,
nvim-host.disabled_variable
nvim-host.dontWrap
Type: submodule
Declared by:
hosts.<name>.nvim-host.disabled_variable
vim.g.<value> will be set to 0 when the nvim host is disabled
Type: non-empty line
Default:
"loaded_‹name›_provider"
Declared by:
hosts.<name>.nvim-host.dontWrap
If true, do not process any hosts.*.nvim-host options for this host other than:
nvim-host.enable,
nvim-host.package,
nvim-host.var_path,
nvim-host.enabled_variable,
nvim-host.disabled_variable
Type: boolean
Default:
false
Declared by:
hosts.<name>.nvim-host.enable
Enable this nvim host program.
If enabled it will be added to the path alongside the nvim wrapper.
It will also propagate options provided in this set to the nvim wrapper.
Type: boolean
Default:
true
Declared by:
hosts.<name>.nvim-host.enabled_variable
vim.g.<value> will be set to the path to this wrapped host when the nvim host is enabled
Type: non-empty line
Default:
"‹name›_host_prog"
Declared by:
hosts.<name>.nvim-host.package
The full path to be added to the PATH alongside the main nvim wrapper.
By default, the binary from this host wrapper module will be used.
This is the path which gets wrapped in the context of the nvim wrapper by the nvim-host options
This allows you to wrap this path in the context of the overall nvim derivation,
and thus have access to that path via placeholder "out"
Type: non-empty line
Default:
"/nix/store/j4j66aph0ab5qhkddicyb3aibjjrfx6d-hello-2.12.2/bin/hello"
Declared by:
hosts.<name>.nvim-host.var_path
The path to be added to vim.g.<enabled_variable>
By default, the result of wrapping nvim-host.package with the
other nvim-host.* options in the context of the outer neovim wrapper will be used.
Type: non-empty line
Default:
"/nix/store/bfrmv3i2gwa6pbjn5sizgw787nz2m8d5-mdbook-0.5.2/bin/nvim-‹name›"
Declared by:
info
This wrapper module generates an info plugin.
Add items here to populate require('nix-info').info
You can change the name nix-info with settings.info_plugin_name
You may get the value of settings.info_plugin_name in lua with
vim.g.nix_info_plugin_name
The info plugin also has a safe indexing helper function.
require(vim.g.nix_info_plugin_name)(
null, -- default value
"info", -- start indexing!
"path",
"to",
"nested",
"info",
"value" -- will return the value, or the specified default
)
Type: lua value
Default:
{ }
Declared by:
nvim-lib.mkPlugin
A function used to build plugins not in nixpkgs!
If you had a flake input like:
inputs.treesj = {
url = "github:Wansmer/treesj";
flake = false;
};
You could install it like:
config.specs.treesj = {
data = config.nvim-lib.mkPlugin "treesj" inputs.treesj;
info = { };
config = "local info = ...; require('treesj').setup(info);";
};
Or, if you wanted to do the config in your main lua files, just install it:
config.specs.treesj = config.nvim-lib.mkPlugin "treesj" inputs.treesj;
You can use any fetcher, not just flake inputs, but flake inputs are tracked for you!
Type: (read-only) function that evaluates to a(n) function that evaluates to a(n) package
Default:
<function>
Declared by:
settings
settings for the neovim derivation.
You may pass extra values just like config.info
These will be made available in neovim via
require('nix-info').settings
require('nix-info')("default_value", "settings", "path", "to", "item")
require(vim.g.nix_info_plugin_name).settings
Type: open submodule of lua value
Default:
{ }
Declared by:
settings.aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
settings.block_normal_config
By default, we block the config in vim.fn.stdpath('config').
The default settings.config_directory is vim.fn.stdpath('config')
so we don’t need to run it twice, and when you wrap it,
you usually won’t want config from other sources.
But you may make this false, and if you do so, the normal config directory will still be added to the runtimepath.
However, the init.lua of the normal config directory will not be ran.
Type: boolean
Default:
true
Declared by:
settings.compile_generated_lua
Compile the generated lua files this wrapper creates beforehand
Set to "debug" to retain debug information
Only compiles the generated files, does not compile the whole packpath, or your configuration.
That would technically be possible to add yourself via a config.drv hook,
however, it is recommended to use vim.loader.enable() to handle those instead.
This option exists because the affected files are ran before you have the opportunity to enable it.
Type: one of true, false, “debug”
Default:
true
Declared by:
settings.config_directory
The directory to use as the new config directory.
May be a wlib.types.stringable or a types.luaInline
Type: str|path|drv or inline lua
Default:
{
_type = "lua-inline";
expr = "vim.fn.stdpath('config')";
}
Declared by:
settings.dont_link
Don’t link extra paths from the neovim derivation to the final output.
This, in conjunction with binName option, allows you to install multiple
neovims via home.packages or environment.systemPackages without path collisions.
Type: boolean
Default:
false
Declared by:
settings.info_plugin_name
The name to use to require the info plugin
May not be empty, may not contain dots or newlines.
Type: non-empty line
Default:
"nix-info"
Declared by:
settings.nvim_lua_env
A function that will be supplied to config.package.lua.withPackages
lp: [ lp.inspect ];
Type: function that evaluates to a(n) list of package
Default:
<function>
Declared by:
specCollect
contains a function which takes 2 arguments.
config.specCollect = fn: first: builtins.foldl' fn first mappedSpecs;
mappedSpecs in the above snippet is the result after all config.specMaps have been applied.
You will recieve JUST the specs, unlike config.specMaps, which recieves specs wrapped in an outer set with more info
This function offered by this option allows you to use items collected from the final specs, to provide them to other options.
Type: (read-only) function that evaluates to a(n) function that evaluates to a(n) list of raw value
Declared by:
specMaps
supply a DAL list of functions
Each function recieves the WHOLE final list of specs, in a particular format.
Each one recieves [ { name = "attrName"; type = "spec" | "parent"; value = spec; } /* ... */ ]
Each one returns the same structure, but with your alterations.
The returned list will REPLACE the original list for the next function in specMaps, and then for the wrapper for sorting.
specCollect gets the final specs after this has ran and everything has been sorted.
You can only have at most 1 parent per attribute name or it errors.
Be VERY careful with this option.
However, this is your chance to have full control to process options you added via specMods
config.specCollect can only collect, and while it is easier and safer than this option, this option has MUCH more control.
This option gets and returns a list of sets with meta info and the spec for each value in config.specs.
Type:
list of spec with main field: data of function that evaluates to a(n) list of attribute set of raw value
Default:
[ ]
Declared by:
specMaps.*.enable
Enable the function to run on the full list of specs
Type: boolean
Default:
true
Declared by:
specMods
extra module for the plugin spec submodules (provided to wlib.types.specWith)
These modules recieve some specialArgs!
parentSpec, parentOpts, and parentName
If the spec is a parent, these will be null
If the spec is a child, parentSpec will be the config argument of the parent spec.
Likewise, parentOpts will be the options argument and parentName the name argument.
You may use this to change defaults and allow parent overrides of the default to propagate default values to child specs.
config.specMods = {
parentSpec, config, parentOpts, options, parentName, ...
}: {
config.collateGrammars = lib.mkDefault (parentSpec.collateGrammars or false);
};
You could also declare entirely new items for the spec to process with specMaps and specCollect.
Type: module
Default:
{ }
Declared by:
specMods.after
Sort this spec after the list of spec names
Type: list of string
Default:
[ ]
Declared by:
specMods.before
Sort this spec before the list of spec names
Type: list of string
Default:
[ ]
Declared by:
specMods.config
A snippet of config for this spec.
Type: null or strings concatenated with “\n”
Default:
null
Declared by:
specMods.enable
Enable the value
If this is in the inner list, then the default value from the parent spec will be used.
Type: boolean
Default:
true
Declared by:
specMods.info
Can be received in .config with local info, _, _ = ...
Type: lua value
Default:
{ }
Declared by:
specMods.lazy
Can be received in .config with local _, _, lazy = ...
If this is in the inner list, then the default value from the parent spec will be used.
Type: boolean
Default:
false
Declared by:
specMods.name
The name of this spec in the DAG of specs
May differ from the name of the plugin,
which is controlled by the pname option.
Type: null or string
Default:
"‹name›"
Declared by:
specMods.pname
Can be received in .config with local _, pname, _ = ...
Type: null or string
Default:
null
Declared by:
specMods.type
The language for the config field of this spec.
(Only applies to the config field, not the info field)
If this is in the inner list, then the default value from the parent spec will be used.
Type: one of “lua”, “fnl”, “vim”
Default:
"lua"
Declared by:
specs
Plugins are provided via the config.specs option.
It takes a set of plugins, or a set of lists of plugins.
Everything that takes a plugin can instead be a spec
This means you could pass a direct plugin or a spec with the plugin as its .data field.
For the outer attribute set, this means the value or the .data field may be a plugin (a stringable value), null, or a list of specs
And for the contained lists, the values or .data fields may be a plugin or null
Many options when set in the outer set will propagate to the contained lists.
For example, the value for lazy does this, allowing you to specify a list of plugins all to be loaded lazily by default.
This is controlled by the specMods option.
# Direct plugin path
config.specs.gitsigns = pkgs.vimPlugins.gitsigns-nvim;
config.specs.treesj = {
data = pkgs.vimPlugins.treesj;
config = "require('treesj').setup({})";
};
# Spec with info values (in fennel!)
config.specs.lualine = {
data = pkgs.vimPlugins.lualine-nvim;
type = "fnl";
info = { # mkLuaInline in info still just makes lua even if its fennel type
theme = lua.mkLuaInline "[[catppuccin]]";
};
# but here we can use fennel!
config = ''
(local (opts name) ...)
((. (require "lualine") setup) {
:options { :theme info.theme }
})
'';
};
# List of specs (DAL inside the DAG)
config.specs.completion-plugins = {
lazy = true; # lazy will propagate to the contained specs.
data = [
{
name = "blink-cmp";
data = pkgs.vimPlugins.blink-cmp;
}
# values can be specs or plugins here too!
# some values will propagate from the parent.
# you can change this, or add your own options via `config.specMods`!
pkgs.vimPlugins.fzf-lua-nvim;
];
};
Built-in Spec Fields
data: The plugin package to installconfig: Configuration code (lua by default, can be vimscript or fennel)info: Lua values to be accessed in config vialocal info, pname, lazy = ...lazy: Whether to load the plugin lazily (default: false) Propagates to child specs.type: Language for config field -"lua","vim", or"fnl"(default:"lua") Propagates to child specs.pname: Optional package name, accessible in configenable: Enable or disable this spec (default: true) Propagates to child specs.name: Allows this spec to be referenced by thebeforeandafterfields of other specsbefore: A list of specs which this spec will run its configuration beforeafter: A list of specs which this spec will run its configuration after
…and also some extra ones set via specMods by default.
pluginDeps: Install plugins from.dependenciesattribute on this plugin Propagates to child specs. Default"startup", allows"lazy"andfalseas well.collateGrammars: Collate the grammars of all plugins in this spec into a single grammar Propagates to child specs. Defaulttrue.runtimeDeps: Install values from.runtimeDepsattribute on this plugin to thePATH. Propagates to child specs. Default"suffix", allows"prefix"andfalseas well.autoconfig: Add configuration code from.passthru.initLuaattribute on this plugin. Propagates to child specs. Value is of type boolean, with a default oftrue.
TIP
The main init.lua of your config directory is added to the specs DAG under the name INIT_MAIN.
By default, the specs will run after it. Add before = [ "INIT_MAIN" ] to the spec to run before it.
Using specMods for Customization
The specMods option allows you to define extra options and processing for specs.
It receives parentSpec and parentOpts via specialArgs, allowing child specs to access and inherit from their parents.
These values will be null if the spec is a parent spec, and contain the config and options arguments of their parent spec if they are in a contained list instead.
config.specMods = { parentSpec, ... }: {
# declare more spec fields you can process either here, or after with other options!
options.myopt = lib.mkOption {
type = lib.types.bool;
default = parentOpts.myopt or false;
desc = "A description for myopt";
};
# Or change a default!
config.collateGrammars = parentSpec.collateGrammars or false;
config.type = parentSpec.type or "fnl";
};
These extra modules will be provided to the modules argument that creates the specs from wlib.types.specWith
You may then need to process the backend of these new options via config.specMaps or config.specCollect.
This is more complex, with specCollect being the next simplest option followed by specMaps which is hardest, but it gives amazing flexibility for adding behaviors!
Type:
attribute set of spec with main field: data of (null or str|path|drv or list of spec with main field: data of (null or str|path|drv))
Default:
{ }
Declared by:
specs.<name>.after
Sort this spec after the list of spec names
Type: list of string
Default:
[ ]
Declared by:
specs.<name>.before
Sort this spec before the list of spec names
Type: list of string
Default:
[ ]
Declared by:
specs.<name>.config
A snippet of config for this spec.
Type: null or strings concatenated with “\n”
Default:
null
Declared by:
specs.<name>.data
A list of specs or plugins, or a plugin, or null
A plugin can be a derivation, or an impure string path for testing!
Type:
null or str|path|drv or list of spec with main field: data of (null or str|path|drv)
Declared by:
specs.<name>.enable
Enable the value
If this is in the inner list, then the default value from the parent spec will be used.
Type: boolean
Default:
true
Declared by:
specs.<name>.info
Can be received in .config with local info, _, _ = ...
Type: lua value
Default:
{ }
Declared by:
specs.<name>.lazy
Can be received in .config with local _, _, lazy = ...
If this is in the inner list, then the default value from the parent spec will be used.
Type: boolean
Default:
false
Declared by:
specs.<name>.name
The name of this spec in the DAG of specs
May differ from the name of the plugin,
which is controlled by the pname option.
Type: null or string
Default:
"‹name›"
Declared by:
specs.<name>.pname
Can be received in .config with local _, pname, _ = ...
Type: null or string
Default:
null
Declared by:
specs.<name>.type
The language for the config field of this spec.
(Only applies to the config field, not the info field)
If this is in the inner list, then the default value from the parent spec will be used.
Type: one of “lua”, “fnl”, “vim”
Default:
"lua"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
NOTE: wrapperVariants:
In this module, config.wrapperVariants behaves slightly differently.
If you use it, your package is not guaranteed to be compatible with multiple installs.
The config.wrapperVariants.<name>.package field defaults to pkgs.<name> if not set.
The config.wrapperVariants.<name>.mirror field is false and cannot be set to true.
Use it if you need to wrap an extra package in the context of your neovim derivation,
but config.hosts was not suitable for the task.
Again, use of this option is very likely to cause path collisions with multiple simultaneous installations.
Tips and Tricks:
The main init.lua of your config directory is added to the specs DAG under the name INIT_MAIN.
By default, the specs will run after it. Add before = [ "INIT_MAIN" ] to the spec to run before it.
- Your
config.settings.config_directorycan point to an impure path (or lua inline value)
Use this for a quick feedback mode while editing, and then switch it back to the pure path when you are done! (or make an option for it)
The wrapper makes a lot of information available to you in your lua config via the info plugin!
local nixInfo = require(vim.g.nix_info_plugin_name)
local default = nil
local value = nixInfo(default, "path", "to", "value", "in", "plugin")
It is just a table! Run :=require(vim.g.nix_info_plugin_name) to look at it!
A useful function to see if nix installed a plugin for you is:
local nixInfo = require(vim.g.nix_info_plugin_name)
local function get_nix_plugin_path(name)
return nixInfo(nil, "plugins", "lazy", name) or nixInfo(nil, "plugins", "start", name)
end
For another example, you might want to tell your info plugin about the top-level specs which you have enabled, which you can do like this in your module:
config.info.cats = builtins.mapAttrs (_: v: v.enable) config.specs;
And then get it in lua with:
local nixInfo = require(vim.g.nix_info_plugin_name)
local cat_is_present = nixInfo(false, "info", "cats", "<specs_attribute_name>")
You could also do similar with
options.settings.cats = lib.mkOption {
readOnly = true;
type = lib.types.attrsOf lib.types.raw;
default = builtins.mapAttrs (_: v: v.enable) config.specs;
};
# nixInfo(false, "settings", "cats", "<specs_attribute_name>")
- lazy loading
If you mark a spec as lazy, (or mark a parent spec and don’t override the value in the child spec by default),
it will be placed in pack/myNeovimPackages/opt/<pname> on the runtime path.
It will not be loaded yet. Use vim.cmd.packadd("<pname>") to load it via lua (or vimscript or fennel) at a time of your choosing.
There are great plugins for this.
See lze and lz.n, which work beautifully with this method of installing plugins.
They also work great with the builtin neovim plugin manager, vim.pack.add!
- To use a different version of
neovim, setconfig.packageto the version you want to use!
config.package = inputs.neovim-nightly-overlay.packages.${pkgs.stdenv.hostPlatform.system}.neovim;
- In order to prevent path collisions when installing multiple neovim derivations via
home.packagesorenvironment.systemPackages
# set this to true
config.settings.dont_link = true;
# and make sure these dont share values:
config.binName = "nvim";
config.settings.aliases = [ ];
- Use
nvim-lib.mkPluginto build plugins from sources outside nixpkgs (e.g., git flake inputs)
inputs.treesj = {
url = "github:Wansmer/treesj";
flake = false;
};
config.specs.treesj = config.nvim-lib.mkPlugin "treesj" inputs.treesj;
- Building many plugins from outside
nixpkgsat once
In your flake inputs, if you named your inputs like so:
inputs.plugins-treesitter-textobjects = {
url = "github:nvim-treesitter/nvim-treesitter-textobjects/main";
flake = false;
};
You could identify them and build them as plugins all at once!
Here is a useful module to import which gives you a helper function
in config.nvim-lib for that!
{ config, lib, ... }: {
options.nvim-lib.pluginsFromPrefix = lib.mkOption {
type = lib.types.raw;
readOnly = true;
default =
prefix: inputs:
lib.pipe inputs [
builtins.attrNames
(builtins.filter (s: lib.hasPrefix prefix s))
(map (
input:
let
name = lib.removePrefix prefix input;
in
{
inherit name;
value = config.nvim-lib.mkPlugin name inputs.${input};
}
))
builtins.listToAttrs
];
};
}
And then you have access to the plugins like this!:
inputs:
{ config, ... }: let
neovimPlugins = config.nvim-lib.pluginsFromPrefix "plugins-" inputs;
in {
imports = [ ./the_above_module.nix ];
specs.treesitter-textobjects = neovimPlugins.treesitter-textobjects;
}
- Change defaults and allow parent values to propagate default values to child specs:
config.specMods = { parentSpec, ... }: {
config.collateGrammars = lib.mkDefault (parentSpec.collateGrammars or false);
};
You have full control over them via the module system! This module will apply to the wlib.types.spec type of both specs in both the outer set and inner lists!
In the outer set, parentSpec is null and in the inner lists, it receives the config argument from the outer set!
It also receives parentOpts, which contains the options argument, and parentName with the name argument of the outer spec.
It also receives the normal module arguments, like config from the current module.
- You may want to move the installation of things like language servers into your specs. You can do that!
{ config, lib, wlib, ... }: {
config.specMods = {
options.extraPackages = lib.mkOption {
type = lib.types.listOf wlib.types.stringable;
default = [ ];
description = "a extraPackages spec field to put packages to suffix to the PATH";
};
};
config.extraPackages = config.specCollect (acc: v: acc ++ (v.extraPackages or [ ])) [ ];
}
- Use
specMapsfor advanced spec processing only whenspecModsandspecCollectis not flexible enough.
specMaps has free-reign to modify the whole structure of specs provided as desired after the module evaluation,
before specCollect runs, and before the wrapper evaluates the builtin fields of the specs.
Be careful with this option, but an advanced user might use this to preprocess the items in truly amazing ways!
This also means items in specCollect may occasionally be missing fields, do not rely on them being there when using it! Use or to catch indexing errors.
- Make a new host!
# an attribute set of wrapper modules
config.hosts.neovide =
{
lib,
wlib,
pkgs,
...
}:
{
imports = [ wlib.modules.default ];
config.nvim-host.enable = lib.mkDefault false;
config.package = pkgs.neovide;
# also offers nvim-host wrapper arguments which run in the context of the final nvim drv!
config.nvim-host.flags."--neovim-bin" = "${placeholder "out"}/bin/${config.binName}";
};
# This one is included!
# To add a wrapped $out/bin/${config.binName}-neovide to the resulting neovim derivation
config.hosts.neovide.nvim-host.enable = true;
- Non-nix compatibility:
If you always use the fetcher function form to access items in the plugin from nix, then this mostly takes care of non-nix compatibility. Non-nix compatibility meaning, trying to use the same config directory without using nix to install it.
do
local ok = pcall(require, vim.g.nix_info_plugin_name)
if not ok then
package.loaded[vim.g.nix_info_plugin_name] = setmetatable({}, {
__call = function (_, default) return default end
})
end
require(vim.g.nix_info_plugin_name).isNix = vim.g.nix_info_plugin_name ~= nil
end
You would have to have a file that installs the plugins with vim.pack.add if not using nix,
and install the lsps some other way as well.
As a reminder, the fetcher function form is:
local nixInfo = require(vim.g.nix_info_plugin_name)
local default = nil
local value = nixInfo(default, "path", "to", "value", "in", "plugin")
- Stylix colorscheme integration (requires somewhere with stylix installed to get the colors from):
{ pkgs, ... }: {
config.specs.base16 = {
# install a plugin to handle the colors
data = pkgs.vimPlugins.mini-base16;
# run before the main init.lua
before = [ "INIT_MAIN" ];
# get the colors from your system and pass it
info = pkgs.lib.filterAttrs (
k: v: builtins.match "base0[0-9A-F]" k != null
) your-system-config.lib.stylix.colors.withHashtag;
# call the plugin with the colors
config = /* lua */ ''
local info, pname, lazy = ...
require("mini.base16").setup({
palette = info,
})
'';
};
}
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
hosts.<name>.nvim-host.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
hosts.<name>.nvim-host.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
hosts.<name>.nvim-host.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
hosts.<name>.nvim-host.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
hosts.<name>.nvim-host.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
hosts.<name>.nvim-host.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
hosts.<name>.nvim-host.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
hosts.<name>.nvim-host.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
hosts.<name>.nvim-host.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
hosts.<name>.nvim-host.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
hosts.<name>.nvim-host.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
hosts.<name>.nvim-host.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
hosts.<name>.nvim-host.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
hosts.<name>.nvim-host.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
hosts.<name>.nvim-host.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation neovim-unwrapped-0.11.6>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"nvim"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/nvim"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
hosts.<name>.apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
hosts.<name>.binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"hello"
Declared by:
hosts.<name>.builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
hosts.<name>.drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
hosts.<name>.eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
hosts.<name>.exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/hello"
Declared by:
hosts.<name>.extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
hosts.<name>.meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
hosts.<name>.meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
hosts.<name>.meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
hosts.<name>.meta.maintainers.*.github
GitHub username
Type: string
Declared by:
hosts.<name>.meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
hosts.<name>.meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
hosts.<name>.meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
hosts.<name>.meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
hosts.<name>.outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
hosts.<name>.overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
hosts.<name>.overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
hosts.<name>.overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
hosts.<name>.overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
hosts.<name>.overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
hosts.<name>.overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
hosts.<name>.package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
hosts.<name>.passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
hosts.<name>.pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
hosts.<name>.sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
hosts.<name>.wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
hosts.<name>.wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation hello-2.12.2>
Declared by:
hosts.<name>.wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"debug"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation neovim-unwrapped-0.11.6>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.niri
wrapperModules/n/niri
This module is made possible by: Patrick Widmer
"config.kdl"
Configuration file for Niri. See https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction
Type: submodule
Default:
{
path = <derivation niri.kdl>;
}
Example:
''
input {
keyboard {
numlock
}
touchpad {
tap
natural-scroll
}
focus-follows-mouse = {
_attrs = { max-scroll-amount = "0%"; };
};
}
''
Declared by:
"config.kdl".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"config.kdl".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
settings
Niri configuration settings. See https://yalter.github.io/niri/Configuration%3A-Introduction.html
Type: open submodule of (attribute set)
Default:
{ }
Declared by:
settings.binds
Bindings of niri
Type: attribute set
Default:
{ }
Example:
{
"Mod+0" = {
focus-workspace = 0;
};
"Mod+Escape" = {
_attrs = {
allow-inhibiting = false;
};
toggle-keyboard-shortcuts-inhibit = null;
};
"Mod+J" = {
focus-column-or-monitor-left = null;
};
"Mod+N" = {
spawn = [
"alacritty"
"msg"
"create-windown"
];
};
"Mod+T" = {
spawn-sh = "alacritty";
};
}
Declared by:
settings.extraConfig
Escape hatch string option added to the config file for options that might not be representable otherwise
Type: string
Default:
""
Declared by:
settings.layer-rules
List of layer rules
Type: list of (attribute set)
Default:
[ ]
Example:
[
{
block-out-from = "screen-capture";
matches = [
{
namespace = "^notifications$";
}
];
opacity = 0.8;
}
]
Declared by:
settings.layout
Layout definitions
Type: attribute set
Default:
{ }
Example:
{
border = {
active-color = "#f5c2e7";
inactive-color = "#313244";
width = 3;
};
focus-ring = {
off = null;
};
}
Declared by:
settings.outputs
Output configuration
Type: attribute set
Default:
{ }
Example:
{
DP-3 = {
background-color = "#003300";
hot-corners = {
off = null;
};
};
}
Declared by:
settings.spawn-at-startup
List of commands to run at startup. The first element in a passed list will be run with the following elements as arguments
Type: list of (string or list of string)
Default:
[ ]
Example:
[
"hello"
[
"nix"
"build"
]
]
Declared by:
settings.window-rules
List of window rules
Type: list of (attribute set)
Default:
[ ]
Example:
[
{
excludes = [
{
app-id = "org.keepassxc.KeePassXC";
}
];
matches = [
{
app-id = ".*";
}
];
open-floating = false;
open-focused = false;
}
]
Declared by:
settings.workspaces
Named workspace definitons
Type: attribute set of (null or anything)
Default:
{ }
Example:
{
bar = null;
foo = {
open-on-output = "DP-3";
};
}
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
NIRI_CONFIG = {
after = [ ];
before = [ ];
data = "/nix/store/jg9adp07pi6idh63d1zcazv5ja8a7sqf-niri.kdl";
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation niri-25.11>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"niri"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/niri"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"doc"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation niri-25.11>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.notmuch
wrapperModules/n/notmuch
This module is made possible by: birdee
configFile
Path or inline definition of the generated Notmuch configuration file.
By default, this is automatically created from the settings option
using the INI format generator.
Type: submodule
Default:
{
path = "/nix/store/hbzy4hxm37lpc3xin49q6zsnrh3rzlan-notmuch.ini";
}
Declared by:
configFile.content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
configFile.path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
settings
INI-style configuration for Notmuch.
This option defines the contents of the notmuch.ini configuration file.
Use attribute sets to specify sections and key-value pairs.
Example:
settings = {
user = { name = "Alice"; primary_email = "alice@example.org"; };
database = { path = "Maildir"; };
};
Type: attribute set of section of an INI file (attrs of INI atom (null, bool, int, float or string))
Default:
{
database = {
mail_root = "Maildir";
path = "Maildir";
};
}
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
NOTMUCH_CONFIG = {
after = [ ];
before = [ ];
data = "/nix/store/hbzy4hxm37lpc3xin49q6zsnrh3rzlan-notmuch.ini";
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation notmuch-0.39>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"notmuch"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/notmuch"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"man"
"info"
"bindingconfig"
"emacs"
"vim"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation notmuch-0.39>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.nushell
wrapperModules/n/nushell
This module is made possible by: birdee
"config.nu"
The main Nushell configuration file.
Provide either .content to inline the file contents or .path to reference an existing file.
This file is passed to Nushell using --config, and controls general shell behavior,
key bindings, and built-in command settings.
Type: submodule
Default:
{
content = "";
}
Declared by:
"config.nu".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"config.nu".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
"env.nu"
The Nushell environment configuration file.
Provide either .content to inline the file contents or .path to reference an existing file.
This file is passed to Nushell using --env-config, and is typically used to define
environment variables or startup commands that apply to all shells.
Type: submodule
Default:
{
content = "";
}
Declared by:
"env.nu".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"env.nu".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
"="
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = <derivation config.nu>;
esc-fn = null;
name = null;
sep = null;
};
"--env-config" = {
after = [ ];
before = [ ];
data = <derivation env.nu>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation nushell-0.110.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"binary"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"nu"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/nu"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation nushell-0.110.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.opencode
wrapperModules/o/opencode
This module is made possible by: birdee
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
OPENCODE_CONFIG = {
after = [ ];
before = [ ];
data = <derivation OPENCODE_CONFIG.json>;
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation opencode-1.1.53>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"opencode"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/opencode"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation opencode-1.1.53>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.ov
wrapperModules/o/ov
This module is made possible by: rencire
settings
Configuration of ov. See https://github.com/noborus/ov/blob/master/ov.yaml
Type: YAML 1.1 value
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = <derivation ov.yaml>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation ov-0.50.2>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"ov"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/ov"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"doc"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation ov-0.50.2>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.rofi
wrapperModules/r/rofi
This module is made possible by: birdee
"config.rasi"
The main Rofi configuration file (config.rasi).
Provide either .content to inline the generated Rasi text or .path to reference an external file.
By default this file is auto-generated from the values in settings and the selected theme.
It is passed to Rofi using -config.
Type: submodule
Default:
{
content = ''
configuration {
location: 0;
xoffset: 0;
yoffset: 0;
}
'';
}
Declared by:
"config.rasi".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"config.rasi".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
plugins
List of rofi plugins to be installed
Type: list of package
Default:
[ ]
Declared by:
settings
Configuration settings for rofi.
Type: (attribute set of (string or signed integer or boolean or (Rasi literal string) or list of (string or signed integer or boolean or (Rasi literal string)))) or string
Default:
{
location = 0;
xoffset = 0;
yoffset = 0;
}
Declared by:
theme
The Rofi theme specification.
Can be:
- a string or path to an existing
.rasitheme file, - or an attribute set describing Rasi sections and key/value pairs.
When an attribute set is provided, it is rendered to Rasi syntax automatically.
The theme is included in "config.rasi" via an @theme directive.
Type: null or string or absolute path or attribute set of ((attribute set of (string or signed integer or boolean or (Rasi literal string) or list of (string or signed integer or boolean or (Rasi literal string)))) or string)
Default:
null
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"-config" = {
after = [ ];
before = [ ];
data = <derivation config.rasi>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation rofi-2.0.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"rofi"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/rofi"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation rofi-2.0.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.tealdeer
wrapperModules/t/tealdeer
This module is made possible by: birdee
settings
Configuration of tealdeer. See <tealdeer-rs.github.io/tealdeer/config.html>
Type: TOML value
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config-path" = {
after = [ ];
before = [ ];
data = <derivation tealdeer.toml>;
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation tealdeer-1.8.1>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"tldr"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/tldr"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation tealdeer-1.8.1>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.tmux
wrapperModules/t/tmux
This module is made possible by: birdee
aggressiveResize
Value for setw -g aggressive-resize.
Type: boolean
Default:
false
Declared by:
allowPassthrough
Value for set -gq allow-passthrough.
Type: boolean
Default:
true
Declared by:
baseIndex
Value for set -g base-index.
Type: signed integer
Default:
1
Declared by:
clock24
use 24 hour clock instead of 12 hour clock
Type: boolean
Default:
true
Declared by:
configAfter
configuration to run after all tmux plugins are sourced
Type: strings concatenated with “\n”
Default:
""
Declared by:
configBefore
configuration to run before all tmux plugins are sourced
Type: strings concatenated with “\n”
Default:
""
Declared by:
disableConfirmationPrompt
disable the confirmation prompt for kill-window and kill-pane keybindings.
Type: boolean
Default:
true
Declared by:
displayPanesColour
Value for set -g display-panes-colour.
Type: string
Default:
"default"
Declared by:
escapeTime
Value for set -s escape-time.
Type: signed integer
Default:
10
Declared by:
historyLimit
Value for set -g history-limit.
Type: signed integer
Default:
2000
Declared by:
modeKeys
Value for set -g mode-keys.
Type: string
Default:
"emacs"
Declared by:
mouse
Enable mouse mode.
Type: boolean
Default:
true
Declared by:
paneBaseIndex
Value for setw -g pane-base-index.
Type: signed integer
Default:
1
Declared by:
plugins
List of tmux plugins to source.
Type: list of (package or (submodule))
Default:
[ ]
Declared by:
prefix
Set the prefix key for tmux.
Type: string
Default:
"C-b"
Declared by:
secureSocket
Store tmux socket under {file}/run, which is more
secure than {file}/tmp, but as a downside it doesn’t
survive user logout.
Type: boolean
Default:
false
Declared by:
setEnvironment
attrset of environment variables to set when the tmux session is created.
set-environment -g ${key} "${value}"
Type: attribute set of (string or package)
Default:
{ }
Declared by:
shell
set -g default-shell
Type: null or string
Default:
null
Declared by:
sourceSensible
Start with defaults from tmuxPlugins.sensible
Type: boolean
Default:
true
Declared by:
statusKeys
Value for set -g status-keys.
Type: string
Default:
"emacs"
Declared by:
terminal
Value for set -g default-terminal.
Type: string
Default:
"screen"
Declared by:
terminalOverrides
Value for set -ga terminal-overrides.
Type: null or string
Default:
null
Declared by:
updateEnvironment
List of environment variables to update when the tmux session is created.
set-option -ga update-environment <your list of variables>
Type: list of string
Default:
[
"TERM"
"TERM_PROGRAM"
]
Declared by:
vimVisualKeys
v and y keybindings for copy-mode-vi.
Type: boolean
Default:
false
Declared by:
visualActivity
Value for set -g visual-activity.
Type: boolean
Default:
false
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"-f" = {
after = [ ];
before = [ ];
data = "/nix/store/3nhz77i0kx447gnr18iwsa50g1f2zxj6-tmux.conf";
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation tmux-3.6a>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"tmux"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/tmux"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
"man"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation tmux-3.6a>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.vim
wrapperModules/v/vim
This module is made possible by: Ameer Taweel
optionalPlugins
List of vim plugins to install.
Manually loadable by calling :packadd $plugin-name.
If a plugin has a dependency that is not explicitly listed in
{option}optionalPlugins, that dependency will always be added to
{option}plugins to avoid confusion.
To get a list of supported plugins run:
{command}nix-env -f '<nixpkgs>' -qaP -A vimPlugins.
Type: list of package
Default:
[ ]
Example:
[ pkgs.vimPlugins.elm-vim ]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
plugins
List of vim plugins to install.
Loaded on launch.
To get a list of supported plugins run:
{command}nix-env -f '<nixpkgs>' -qaP -A vimPlugins.
Type: list of package
Default:
[
<derivation vimplugin-vim-sensible-2.0-unstable-2024-06-08>
]
Example:
[ pkgs.vimPlugins.YankRing-vim ]
Declared by:
vimrc
.vimrc config
Type: strings concatenated with “\n”
Default:
""
Example:
''
set nocompatible
set nobackup
''
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation vim>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"vim"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/vim"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation vim>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.waybar
wrapperModules/w/waybar
This module is made possible by: Patrick Widmer
configFile
Waybar configuration settings file. See https://github.com/Alexays/Waybar/wiki/Configuration
Type: submodule
Default:
{
path = <derivation waybar-config>;
}
Example:
{
content = ''
{
"height": 30,
"layer": "top",
"modules-center": [],
"modules-left": [
"sway/workspaces",
"niri/workspaces"
]
}
'';
}
Declared by:
configFile.content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
configFile.path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
settings
Waybar configuration settings. See https://github.com/Alexays/Waybar/wiki/Configuration
Type: JSON value
Default:
{ }
Example:
{
height = 30;
layer = "top";
modules-center = [ ];
modules-left = [
"niri/workspaces"
"sway/workspaces"
];
position = "top";
}
Declared by:
"style.css"
CSS style for Waybar.
Type: submodule
Default:
{
content = "";
}
Declared by:
"style.css".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"style.css".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config" = {
after = [ ];
before = [ ];
data = "/nix/store/b9475ilnvaqq246499gyrqinynk45rs2-waybar-config";
esc-fn = null;
name = null;
sep = null;
};
"--style" = {
after = [ ];
before = [ ];
data = "/nix/store/9hmckap8w79vcjj181p4ja74k89p470h-style.css";
esc-fn = null;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation waybar-0.15.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"waybar"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/waybar"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation waybar-0.15.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.wezterm
wrapperModules/w/wezterm
This module is made possible by: birdee
lua
The lua derivation used to evaluate the luaEnv option
Type: package
Default:
<derivation luajit-2.1.1741730670>
Declared by:
luaEnv
extra lua packages to add to the lua environment for wezterm
value is to be a function from config.lua.pkgs to list
config.lua.withPackages config.luaEnv
The result will be added to package.path and package.cpath
Type: function that evaluates to a(n) list of package
Default:
<function>
Declared by:
luaInfo
anything other than uncalled nix functions can be put into this option,
within your "wezterm.lua", you will be able to call require('nix-info')
and get the values as lua values
the default "wezterm.lua".content value is return require('nix-info')
This means, by default, this will act like your wezterm config file, unless you want to add some lua in between there.
${placeholder "out"} is useable here and will point to the final wrapper derivation
You may also call require('nix-info')(defaultval, "path", "to", "item")
This will help prevent indexing errors when querying nested values which may not exist.
Type: lua value
Default:
{ }
Declared by:
"wezterm.lua"
The wezterm config file. provide .content, or .path
Type: submodule
Default:
{
content = "return require('nix-info')";
}
Declared by:
"wezterm.lua".content
Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.
Type: strings concatenated with “\n”
Declared by:
"wezterm.lua".path
The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.
Type: str|path|drv
Default:
pkgs.writeText name <content>
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
"="
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{
"--config-file" = {
after = [ ];
before = [ ];
data = "/nix/store/bfrmv3i2gwa6pbjn5sizgw787nz2m8d5-mdbook-0.5.2/wezterm-rc.lua";
esc-fn = <function>;
name = null;
sep = null;
};
}
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation wezterm-0-unstable-2026-01-17>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"wezterm"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/wezterm"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation wezterm-0-unstable-2026-01-17>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.xplr
wrapperModules/x/xplr
This module is made possible by: birdee
defaultConfigLang
The default config language to use for generated config segments. Does not affect the luaInfo option.
Type: one of “fnl”, “lua”
Default:
"lua"
Declared by:
infopath
The default require path for the result of the luaInfo option. Don’t change this unless you have a really good reason to.
Type: string
Default:
"nix-info"
Declared by:
lua
The lua derivation used to evaluate the luaEnv option
Type: package
Default:
<derivation luajit-2.1.1741730670>
Declared by:
luaEnv
extra lua packages to add to the lua environment for xplr
value is to be a function from config.lua.pkgs to list
config.luaEnv = lp: [ lp.inspect ];
The result will be added to package.path and package.cpath
Type: function that evaluates to a(n) list of package
Default:
<function>
Declared by:
luaInfo
luaInfo is a Lua table that can hold arbitrary data you want to expose to your Lua environment.
This table is automatically converted to Lua code and made available under require "nix-info".
config.defaultConfigLang does NOT affect this value.
the name nix-info can be changed via config.infopath option
Type: lua value
Default:
{ }
Declared by:
luaInit
luaInit is a flexible configuration option for providing Lua code that will be executed when the Lua environment for xplr is initialized.
It can be either a simple string of Lua code or a structured DAG (directed acyclic graph) of Lua code snippets with dependencies between them.
The dag type has an extra opts field that can be used to pass in options to the lua code.
It is like the config.luaInfo option, but per entry.
You can then receive it in .data with local opts, name = ...
{ data, after ? [], before ? [], opts ? {}, enable ? true, plugin ? null, type ? config.defaultConfigLang }
Example usage:
luaEnv = lp: [ lp.inspect ];
luaInit.WillRunEventually = ''
print([[
you can also just put a string if you currently don't need opts,
don't have ordering requirements, etc...
config.luaInit.WillRunEventually.data will be this string.
You can still add other stuff later.
]])
'';
luaInit.TESTFILE_1 = {
opts = { testval = 1; };
data = /* lua */''
local opts, name = ...
print(name, require("inspect")(opts), "${placeholder "out"}")
return opts.hooks -- xplr configurations can return hooks
'';
};
luaInit.TESTFILE_2 = {
opts = { testval = 2; };
after = [ "TESTFILE_1" ];
type = "fnl";
data = /* fennel */ ''
(local (opts name) ...)
(print name ((require "inspect") opts) "${placeholder "out"}")
(. opts hooks) ;; xplr configurations can return hooks
'';
};
Here, TESTFILE_1 runs before TESTFILE_2, with their respective options passed in.
WillRunEventually will run at some point, but when is not specified. It could even run between TESTFILE_1 and TESTFILE_2
The resulting generated file is given the name GENERATED_WRAPPER_LUA in the DAG for the config.flags and config.addFlag options, and it is added using -c or --config flag.
xplr accepts an arbitrary number of config files passed via the -C or --extra-config flag to extend this configuration, so you may pass extra yourself if you wish.
Type:
string or attribute set of spec with main field: data of strings concatenated with “\n”
Default:
{ }
Declared by:
plugins
Will be symlinked into a directory added to the LUA_PATH and LUA_CPATH
The name of the plugin via require will be the dag name for the value.
The name in config.infopath is not allowed (default nix-info)
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Declared by:
plugins.<name>.enable
Enable the value
Type: boolean
Default:
true
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[
{
after = [ ];
before = [ ];
data = [
"-c"
"/nix/store/bfrmv3i2gwa6pbjn5sizgw787nz2m8d5-mdbook-0.5.2/xplr-rc.lua"
];
esc-fn = <function>;
name = "GENERATED_WRAPPER_LUA";
}
]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation xplr-1.1.0>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"xplr"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/xplr"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation xplr-1.1.0>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
wlib.wrapperModules.yazi
wrapperModules/y/yazi
This module is made possible by: apetrovic6
settings.keymap
Content of keymap.toml file. See the configuration reference at https://yazi-rs.github.io/docs/configuration/keymap
Type: open submodule of (TOML value)
Default:
{ }
Declared by:
settings.keymap.cmp
Keymap cmp settings See < https://yazi-rs.github.io/docs/configuration/keymap#cmp>
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.confirm
Keymap confirm settings See < https://yazi-rs.github.io/docs/configuration/keymap#confirm>
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.help
Keymap help settings See < https://yazi-rs.github.io/docs/configuration/keymap#help>
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.input
Keymap input settings See https://yazi-rs.github.io/docs/configuration/keymap#input
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.mgr
Keymap mgr settings See https://yazi-rs.github.io/docs/configuration/keymap#mgr
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.pick
Keymap pick settings See https://yazi-rs.github.io/docs/configuration/keymap#pick
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.spot
Keymap spot settings See https://yazi-rs.github.io/docs/configuration/keymap#spot
Type: TOML value
Default:
{ }
Declared by:
settings.keymap.tasks
Keymap tasks settings See https://yazi-rs.github.io/docs/configuration/keymap#tasks
Type: TOML value
Default:
{ }
Declared by:
settings.package
Content of the package.toml file. See configuration reference at https://yazi-rs.github.io/docs/cli/#pm
Type: open submodule of (TOML value)
Default:
{ }
Declared by:
settings.package.plugin
Set for plugin settings and paths. See configuration reference at https://yazi-rs.github.io/docs/cli/#pm
Type: open submodule of (TOML value)
Default:
{ }
Declared by:
settings.package.plugin.deps
List of plugins and dependencies. See configuration reference at https://yazi-rs.github.io/docs/cli/#pm
Type: list of (TOML value)
Default:
[ ]
Declared by:
settings.theme
Content of theme.toml file. See the configuration reference at https://yazi-rs.github.io/docs/configuration/theme
Type: open submodule of (TOML value)
Default:
{ }
Declared by:
settings.theme.app
Theme app settings See < https://yazi-rs.github.io/docs/configuration/theme#app>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.cmp
Theme cmp settings See < https://yazi-rs.github.io/docs/configuration/theme#cmp>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.confirm
Theme confirm settings See < https://yazi-rs.github.io/docs/configuration/theme#confirm>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.filetype
Theme filetype settings See < https://yazi-rs.github.io/docs/configuration/theme#filetype>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.flavor
Theme flawor settings See < https://yazi-rs.github.io/docs/configuration/theme#flavor>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.help
Theme help settings See < https://yazi-rs.github.io/docs/configuration/theme#help>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.icon
Theme icon settings See < https://yazi-rs.github.io/docs/configuration/theme#icon>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.indicator
Theme indicator settings See < https://yazi-rs.github.io/docs/configuration/theme#indicator>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.input
Theme input settings See < https://yazi-rs.github.io/docs/configuration/theme#input>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.mgr
Theme mgr settings See < https://yazi-rs.github.io/docs/configuration/theme#mgr>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.mode
Theme mode settings See < https://yazi-rs.github.io/docs/configuration/theme#mode>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.notify
Theme notify settings See < https://yazi-rs.github.io/docs/configuration/theme#notify>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.pick
Theme pick settings See < https://yazi-rs.github.io/docs/configuration/theme#pick>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.spot
Theme spot settings See < https://yazi-rs.github.io/docs/configuration/theme#spot>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.status
Theme status settings See < https://yazi-rs.github.io/docs/configuration/theme#status>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.tabs
Theme tabs settings See < https://yazi-rs.github.io/docs/configuration/theme#tabs>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.tasks
Theme tasks settings See < https://yazi-rs.github.io/docs/configuration/theme#tasks>
Type: TOML value
Default:
{ }
Declared by:
settings.theme.which
Theme which settings See < https://yazi-rs.github.io/docs/configuration/theme#which>
Type: TOML value
Default:
{ }
Declared by:
settings.vfs
Content of the vfs.toml file. See configuration reference at https://yazi-rs.github.io/docs/configuration/vfs
Type: open submodule of (TOML value)
Default:
{ }
Declared by:
settings.vfs.services
Vfs settings See < https://yazi-rs.github.io/docs/configuration/vfs>
Type: TOML value
Default:
{ }
Declared by:
settings.yazi
Content of yazi.toml file. See the configuration reference at https://yazi-rs.github.io/docs/configuration/yazi
Type: open submodule of (TOML value)
Default:
{ }
Declared by:
settings.yazi.confirm
Confirm settings See https://yazi-rs.github.io/docs/configuration/yazi#confirm
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.input
Input settings See https://yazi-rs.github.io/docs/configuration/yazi#input
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.mgr
Manager settings See https://yazi-rs.github.io/docs/configuration/yazi#mgr
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.open
Open settings See https://yazi-rs.github.io/docs/configuration/yazi#open
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.opener
Opener settings See https://yazi-rs.github.io/docs/configuration/yazi#opener
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.pick
Pick settings See https://yazi-rs.github.io/docs/configuration/yazi#pick
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.plugin
Plugin settings See https://yazi-rs.github.io/docs/configuration/yazi#plugin
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.preview
Preview settings See https://yazi-rs.github.io/docs/configuration/yazi#preview
Type: TOML value
Default:
{ }
Declared by:
settings.yazi.which
Which settings See https://yazi-rs.github.io/docs/configuration/yazi#which
Type: TOML value
Default:
{ }
Declared by:
modules/symlinkScript
Adds extra options compared to the default builderFunction option value.
Imported by wlib.modules.default
aliases
Aliases for the package to also be added to the PATH
Type: list of string
Default:
[ ]
Declared by:
filesToExclude
List of file paths (glob patterns) relative to package root to exclude from the wrapped package.
This allows filtering out unwanted binaries or files.
Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]
Type: list of string
Default:
[ ]
Declared by:
filesToPatch
List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.
Type: list of string
Default:
[
"share/applications/*.desktop"
]
Declared by:
modules/makeWrapper
An implementation of the makeWrapper interface via type safe module options.
Allows you to choose one of several underlying implementations of the makeWrapper interface.
Imported by wlib.modules.default
Wherever the type includes DAG you can mentally substitute this with attrsOf
Wherever the type includes DAL or DAG list you can mentally substitute this with listOf
However they also take items of the form { data, name ? null, before ? [], after ? [] }
This allows you to specify that values are added to the wrapper before or after another value.
The sorting occurs across ALL the options, thus you can target items in any DAG or DAL within this module from any other DAG or DAL option within this module.
The DAG/DAL entries in this module also accept an extra field, esc-fn ? null
If defined, it will be used instead of the value of options.escapingFunction to escape that value.
It also has a set of submodule options under config.wrapperVariants which allow you
to duplicate the effects to other binaries from the package, or add extra ones.
Each one contains an enable option, and a mirror option.
They also contain the same options the top level module does, however if mirror is true,
as it is by default, then they will inherit the defaults from the top level as well.
They also have their own package, exePath, and binName options, with sensible defaults.
addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
wrapperVariants
Allows for you to apply the wrapper options to multiple binaries from config.package (or elsewhere)
They are called variants because they are the same options as the top level makeWrapper options, however, their defaults mirror the values of the top level options.
Meaning if you set config.env.MYVAR = "HELLO" at the top level,
then the following statement would be true by default:
config.wrapperVariants.foo.env.MYVAR.data == "HELLO"
They achieve this by receiving mainConfig and mainOpts via specialArgs,
which contain config and options from the top level.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
wrapperVariants.<name>.addFlag
Wrapper for
–add-flag ARG
Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.addFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.appendFlag
–append-flag ARG
Append the single argument ARG to the invocation of the executable, after any command-line arguments.
This option takes a list. To group them more strongly, option may take a list of lists as well.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of (str|path|drv or list of str|path|drv)
Default:
[ ]
Example:
[
"-v"
"-f"
[
"--config"
./storePath.cfg
]
[
"-s"
"idk"
]
]
Declared by:
wrapperVariants.<name>.appendFlag.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.argv0
–argv0 NAME
Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.
overrides the setting from argv0type if set.
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.argv0type
argv0 overrides this option if not null or unset
Both shell and the nix implementations
ignore this option, as the shell always resolves $0
However, the binary implementation will use this option
Values:
"inherit":
The executable inherits argv0 from the wrapper.
Use instead of --argv0 '$0'.
"resolve":
If argv0 does not include a “/” character, resolve it against PATH.
- Function form:
str -> str
This one works only in the nix implementation. The others will treat it as inherit
Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.
e.g. command_string: "eval \"$(${command_string})\";
It will also be added to the end of the overall DAL,
with the name NIX_RUN_MAIN_PACKAGE
Thus, you can make things run after it, but by default it is still last.
Type: one of “resolve”, “inherit” or function that evaluates to a(n) string
Default:
"inherit"
Declared by:
wrapperVariants.<name>.binName
The name of the file to output to $out/bin/
Type: non-empty line
Default:
"‹name›"
Declared by:
wrapperVariants.<name>.chdir
–chdir DIR
Change working directory before running the executable.
Use instead of --run "cd DIR".
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.chdir.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.enable
Enables the wrapping of this variant
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.env
Environment variables to set in the wrapper.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{
YAZI_CONFIG_HOME = {
after = [ ];
before = [ ];
data = "/nix/store/4x2g8kvzrl7wadfjxfhg49ccsfc4660n-yazi-merged-config";
esc-fn = null;
name = null;
};
}
Example:
{
XDG_DATA_HOME = "/somewhere/on/your/machine";
}
Declared by:
wrapperVariants.<name>.env.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.envDefault
Environment variables to set in the wrapper.
Like env, but only adds the variable if not already set in the environment.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of str|path|drv
Default:
{ }
Example:
{
XDG_DATA_HOME = "/only/if/not/set";
}
Declared by:
wrapperVariants.<name>.envDefault.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.escapingFunction
The function to use to escape shell values
Caution: When using shell or binary implementations,
these will be expanded at BUILD time.
You should probably leave this as is when using either of those implementations.
However, when using the nix implementation, they will expand at runtime!
Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!
Type: function that evaluates to a(n) string
Default:
lib.escapeShellArg
Declared by:
wrapperVariants.<name>.exePath
The location within the package of the thing to wrap.
Type: null or non-empty line
Default:
"bin/‹name›"
Declared by:
wrapperVariants.<name>.extraPackages
Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.flagSeparator
Separator between flag names and values when generating args from flags.
" " for --flag value or "=" for --flag=value
Type: string
Default:
" "
Declared by:
wrapperVariants.<name>.flags
Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.
This option takes a set.
Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }
The sep field may be used to override the value of config.flagSeparator
This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly
Type:
attribute set of spec with main field: data of (null or boolean or str|path|drv or list of str|path|drv)
Default:
{ }
Example:
{
"--config" = ./nixPath;
}
Declared by:
wrapperVariants.<name>.flags.<name>.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.flags.<name>.sep
A per-item override of the default separator used for flags and their values
Type: null or string
Default:
null
Declared by:
wrapperVariants.<name>.mirror
Allows the variant to inherit defaults from the top level
Type: boolean
Default:
true
Declared by:
wrapperVariants.<name>.package
The package to wrap with these options
Type: str|path|drv
Default:
<derivation yazi-26.1.22>
Declared by:
wrapperVariants.<name>.prefixContent
[
[ "ENV" "SEP" "FILE" ]
]
Prefix ENV with contents of FILE and SEP at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.prefixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.prefixVar
–prefix ENV SEP VAL
Prefix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.prefixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runShell
–run COMMAND
Run COMMAND before executing the main program.
This option takes a list.
Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }
This will cause it to be added to the DAG.
If no name is provided, it cannot be targeted.
Type:
list of spec with main field: data of str|path|drv
Default:
[ ]
Declared by:
wrapperVariants.<name>.runShell.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.runtimeLibraries
Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.
Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS
Type: list of package
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent
[
[ "ENV" "SEP" "FILE" ]
]
Suffix ENV with SEP and then the contents of FILE at build time.
Also accepts sets like the other options
[
[ "ENV" "SEP" "FILE" ]
{ data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Declared by:
wrapperVariants.<name>.suffixContent.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.suffixVar
–suffix ENV SEP VAL
Suffix ENV with VAL, separated by SEP.
Type:
list of spec with main field: data of (List of length 3)
Default:
[ ]
Example:
[
[
"LD_LIBRARY_PATH"
":"
"${lib.makeLibraryPath (with pkgs; [ ... ])}"
]
[
"PATH"
":"
"${lib.makeBinPath (with pkgs; [ ... ])}"
]
]
Declared by:
wrapperVariants.<name>.suffixVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.unsetVar
–unset VAR
Remove VAR from the environment.
Type:
list of spec with main field: data of string
Default:
[ ]
Declared by:
wrapperVariants.<name>.unsetVar.*.esc-fn
A per-item override of the default string escape function
Type: null or (function that evaluates to a(n) string)
Default:
null
Declared by:
wrapperVariants.<name>.wrapperImplementation
the nix implementation is the default
It makes the escapingFunction most relevant.
This is because the shell and binary implementations
use pkgs.makeWrapper or pkgs.makeBinaryWrapper,
and arguments to these functions are passed at BUILD time.
So, generally, when not using the nix implementation,
you should always prefer to have escapingFunction
set to lib.escapeShellArg.
However, if you ARE using the nix implementation,
using wlib.escapeShellArgWithEnv will allow you
to use $ expansions, which will expand at runtime.
binary implementation is useful for programs
which are likely to be used in “shebangs”,
as macos will not allow scripts to be used for these.
However, it is more limited. It does not have access to
runShell, prefixContent, and suffixContent options.
Chosing binary will thus cause values in those options to be ignored.
Type: one of “nix”, “shell”, “binary”
Default:
"nix"
Declared by:
lib/core.nix
These are the core options that make everything else possible.
They include the .extendModules, .apply, .eval, and .wrap functions, and the .wrapper itself
They are always imported with every module evaluation.
They are somewhat minimal by design. They pertain to building the derivation, not the wrapper script.
The default builderFunction value provides no options.
The default wrapperFunction is null.
wlib.modules.default provides great values for these options, and creates many more for you to use.
But you may want to wrap your package via different means, provide different options, or provide modules for others to use to help do those things!
Doing it this way allows wrapper modules to do anything you might wish involving wrapping some source/package in a derivation.
Excited to see what ways to use these options everyone comes up with! Docker helpers? BubbleWrap? If it’s a derivation, it should be possible!
apply
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns .config from the lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
binName
The name of the binary output by wrapperFunction to $out/bin
If not specified, the default name from the package will be used.
Type: non-empty line
Default:
"yazi"
Declared by:
builderFunction
Outside of importing wlib.modules.symlinkScript module,
which is included in wlib.modules.default,
This is usually an option you will never have to redefine.
This option takes a function receiving the following arguments:
module arguments + wrapper + pkgs.callPackage
{
wlib,
config,
wrapper,
... # <- anything you can get from pkgs.callPackage
}@initialArgs:
"<buildCommand>"
It is in charge of linking wrapper and config.outputs to the final package.
wrapper is the unchecked result of calling wrapperFunction, or null if one was not provided.
- The function is to return a string which will be added to the buildCommand of the wrapper.
The builtin implementation, and also the wlib.modules.symlinkScript module,
accept either a string to prepend to the returned buildCommand string,
or a derivation to link with lndir
- Alternatively, it may return a function which returns a set like:
{ wlib, config, wrapper, ... }@initialArgs:
drvArgs:
drvArgs // {}
If it does this, that function will be given the final computed derivation attributes,
and it will be expected to return the final attribute set to be passed to pkgs.stdenv.mkDerivation.
Regardless of if you return a string or function,
passthru.wrap, passthru.apply, passthru.eval, passthru.extendModules, passthru.override,
passthru.overrideAttrs will be added to the thing you return, and config.sourceStdenv will be handled for you.
However:
- You can also return a functor with a (required)
mkDerivationfield.
{ config, stdenv, wrapper, wlib, ... }@initialArgs:
{
inherit (stdenv) mkDerivation;
__functor = {
mkDerivation,
__functor,
defaultPhases, # [ "<all stdenv phases>" ... ]
setupPhases, # phases: "if [ -z \"${phases[*]:-}\" ]; then phases="etc..."; fi"
runPhases, # "for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done"
...
}@self:
defaultArgs:
defaultArgs // (if config.sourceStdenv then { } else { buildCommand = ""; }
}
- If you do this:
- You are in control over the entire derivation.
- This means you need to take care of
config.passthruandconfig.sourceStdenvyourself. - The
mkDerivationfunction will be called with the final result of your functor.
As you can see, you are provided with some things to help you via the self argument to your functor.
The generated passthru items mentioned above are given to you as part of what is shown as defaultArgs above
And you are also given some helpers to help you run the phases if needed!
Tip: A functor is a set with a { __functor = self: args: ...; } field.
You can call it like a function and it gets passed itself as its first argument!
Type: function that evaluates to a(n) (string or function that evaluates to a(n) attribute set of raw value)
Default:
<function, args: {config, lib, lndir, wlib, wrapper}>
Declared by:
drv
Extra attributes to add to the resulting derivation.
Cannot affect passthru, or outputs. For that,
use config.passthru, or config.outputs instead.
Also cannot override buildCommand.
That is controlled by the config.builderFunction
and config.sourceStdenv options.
Type: attrsRecursive
Default:
{ }
Declared by:
eval
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the raw lib.evalModules result
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function>
Declared by:
exePath
The relative path to the executable to wrap. i.e. bin/exename
If not specified, the path gained from calling lib.getExe on config.package and subtracting the path to the package will be used.
Type: null or non-empty line
Default:
"bin/yazi"
Declared by:
extendModules
Alias for .extendModules so that you can call it from outside of wlib.types.subWrapperModule types
In addition, it is also a set which stores the function args for the module evaluation. This may prove useful when dealing with subWrapperModules or packages, which otherwise would not have access to some of them.
Type: (read-only) function that evaluates to a(n) raw value
Default:
<function, args: {modules?, prefix?, specialArgs?}>
Declared by:
meta.description
Description of the module.
Accepts either a string, or a set of { pre ? "", post ? "" }
Resulting config value will be a list of { pre, post, file }
Type:
string or { pre ? “”, post ? “” } (converted to [ { pre, post, file } ])
Default:
""
Declared by:
meta.maintainers
Maintainers of this module.
Type: list of (open submodule of attrsRecursive)
Default:
[ ]
Declared by:
meta.maintainers.*.email
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.github
GitHub username
Type: string
Declared by:
meta.maintainers.*.githubId
GitHub id
Type: signed integer
Declared by:
meta.maintainers.*.matrix
Matrix ID
Type: null or string
Default:
null
Declared by:
meta.maintainers.*.name
name
Type: string
Default:
"‹name›"
Declared by:
meta.platforms
Supported platforms
Type: list of strings from enum of lib.platforms.all
Default:
lib.platforms.all
Example:
[
"x86_64-linux"
"aarch64-linux"
]
Declared by:
outputs
Override the list of nix outputs that get symlinked into the final package.
Default is config.package.outputs or [ "out" ] if invalid.
Type: non-empty list of string
Default:
[
"out"
]
Declared by:
overrides
the list of .override and .overrideAttrs to apply to config.package
Accessing config.package will return the package with all overrides applied.
Accepts a list of { data, type ? null, name ? null, before ? [], after ? [] }
If type == null then data must be a function. It will receive and return the package.
If type is a string like override or overrideAttrs, it represents the attribute of config.package to pass the data field to.
If a raw value is given, it will be used as the data field, and type will be null.
config.package = pkgs.mpv;
config.overrides = [
{ # If they don't have a name they cannot be targeted!
type = "override";
after = [ "MPV_SCRIPTS" ];
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.visualizer ];
});
}
{
name = "MPV_SCRIPTS";
type = "override";
data = (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.modernz ];
});
}
# the default `type` is `null`
(pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ [ pkgs.mpvScripts.autocrop ];
}))
{
type = null;
before = [ "MPV_SCRIPTS" ];
data = (pkg: pkg.override (prev: {
scripts = (prev.scripts or []) ++ config.scripts;
}));
}
{ # It was already after "MPV_SCRIPTS" so this will stay where it is
type = "overrideAttrs";
after = [ "MPV_SCRIPTS" ];
data = prev: {
name = prev.name + "-wrapped";
};
}
];
The above will add config.scripts, then modernz then visualizer and finally autocrop
Then it will add -wrapped to the end of config.package’s name attribute.
The sort will not always put the value directly after the targeted value, it fulfils the requested before or after dependencies and no more.
You can modify the specs!
The type supports type merging, so you may redeclare it in order to add more options or change default values.
{ config, lib, wlib, pkgs, ... }:{
options.overrides = lib.mkOption {
type = wlib.types.seriesOf (wlib.types.spec ({ config, ... }: {
options = {};
config = {};
}));
};
}
Type:
series of spec with main field: data of raw value
Default:
[ ]
Declared by:
overrides.*.after
Items that this spec should be ordered after.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.before
Items that this spec should be ordered before.
Type: list of string
Default:
[ ]
Declared by:
overrides.*.data
If type is null, then this is the function to call on the package.
If type is a string, then this is the data to pass to the function corresponding with that attribute.
Type: raw value
Declared by:
overrides.*.name
The name for targeting from the before or after fields of other specs.
If null it cannot be targeted by other specs.
Type: null or string
Default:
null
Declared by:
overrides.*.type
The attribute of config.package to pass the override argument to.
If null, then data receives and returns the package instead.
If null, data must be a function.
If a string, config.package must have the corresponding attribute, and it must be a function.
Type: null or one of “override”, “overrideAttrs” or string
Default:
null
Declared by:
package
The base package to wrap.
This means config.builderFunction will be responsible
for inheriting all other files from this package
(like man page, /share, …)
The config.package value given by this option already has all
values from config.overrides applied to it.
Type: str|path|drv
Declared by:
passthru
Additional attributes to add to the resulting derivation’s passthru.
This can be used to add additional metadata or functionality to the wrapped package.
Anything added under the attribute name configuration will be ignored, as that value is used internally.
Type: attrsRecursive
Default:
{ }
Declared by:
pkgs
The nixpkgs pkgs instance to use.
Required in order to access .wrapper attribute,
either directly, or indirectly.
Type: Nixpkgs package set
Declared by:
sourceStdenv
Run the enabled stdenv phases on the wrapper derivation.
NOTE: often you may prefer to use things like drv.doDist = true;,
or even drv.phases = [ ... "buildPhase" etc ... ]; instead,
to override this choice in a more fine-grained manner
Type: boolean
Default:
true
Declared by:
wrap
Function to extend the current configuration with additional modules. Can accept a single module, or a list of modules. Re-evaluates the configuration with the original settings plus the new module(s).
Returns the updated package.
Type: (read-only) function that evaluates to a(n) package
Default:
<function>
Declared by:
wrapper
The final wrapped package.
You may still call .eval and the rest on the package again afterwards.
Accessing this value without defining pkgs option,
either directly, or via some other means like .wrap,
will cause an error.
Type: (read-only) package
Default:
<derivation yazi-26.1.22>
Declared by:
wrapperFunction
Arguments:
This option takes a function receiving the following arguments:
module arguments + pkgs.callPackage
{
config,
wlib,
... # <- anything you can get from pkgs.callPackage
}
The result of this function is passed DIRECTLY to the value of the builderFunction function.
The relative path to the thing to wrap from within config.package is config.exePath
You should wrap the package and place the wrapper at "$out/bin/${config.binName}"
Type: null or (function that evaluates to a(n) raw value)
Default:
null
Declared by:
