wlib.makeWrapper set documentation
wlib.makeWrapper.wrapAll
The default config.wrapperFunction value for the wlib.modules.makeWrapper module
Generates build instructions for wrapping the main target and all enabled variants.
Usage:
wlib.makeWrapper.wrapAll {
inherit config;
inherit (pkgs) callPackage; # or `inherit pkgs`;
};
Arguments:
pkgs(set either this orcallPackage): Package set providingcallPackage.callPackage(set either this orpkgs): calls the wrapper builder.config(required): Configuration attribute set.wrapperImplementation(optional): Path or function for the wrapper implementation.
Requirements on config:
- Must define
wrapperPaths.input,wrapperPaths.placeholder,wrapperPaths.relDir,outputName. - May include options from
wlib.modules.makeWrapper.
Behavior:
- Wraps the main target and all enabled variants.
- Wraps the path at
config.wrapperPaths.input - Outputs it to
config.wrapperPaths.placeholder - Wraps the paths at
config.wrapperVariants.*.wrapperPaths.input - Outputs to
config.wrapperVariants.*.wrapperPaths.placeholder
Returns: A string containing build instructions to append to a derivation.
It also takes as an argument wrapperImplementation
You may define a function that receives config, wlib, and arguments from callPackage
and returns a string of build instructions, that follows similar behavior.
You may use the other functions in wlib.makeWrapper to help with this.
wlib.makeWrapper.wrapMain
Generates build instructions for wrapping only the main target.
Usage:
wlib.makeWrapper.wrapMain {
inherit config;
inherit (pkgs) callPackage; # or `inherit pkgs`;
};
Arguments:
pkgs(set either this orcallPackage): Package set providingcallPackage.callPackage(set either this orpkgs): calls the wrapper builder.config(required): Configuration attribute set.wrapperImplementation(optional): Path or function for the wrapper implementation.
Requirements on config:
- Must define
wrapperPaths.input,wrapperPaths.placeholder,wrapperPaths.relDir,outputName. - May include options from
wlib.modules.makeWrapper.
Behavior:
- Wraps only the main target (no variants).
- Wraps the path at
config.wrapperPaths.input - Outputs to
config.wrapperPaths.placeholder
Returns: A string containing build instructions to append to a derivation.
It also takes as an argument wrapperImplementation
You may define a function that receives config, wlib, and arguments from callPackage
and returns a string of build instructions, that follows similar behavior.
You may use the other functions in wlib.makeWrapper to help with this.
- structured function argument
-
pkgs-
Function argument
callPackage-
Function argument
config-
Function argument
wrapperImplementation-
Function argument
wlib.makeWrapper.wrapVariants
Generates build instructions for wrapping all enabled variants, excluding the main target.
Usage:
wlib.makeWrapper.wrapVariants {
inherit config;
inherit (pkgs) callPackage; # or `inherit pkgs`;
};
Arguments:
pkgs(set either this orcallPackage): Package set providingcallPackage.callPackage(set either this orpkgs): calls the wrapper builder.config(required): Configuration attribute set.wrapperImplementation(optional): Path or function for the wrapper implementation.
Requirements on config:
- Must define
wrapperPaths.input,wrapperPaths.placeholder,wrapperPaths.relDir,outputName. - Must define
wrapperVariantsas an attribute set. - May include options from
wlib.modules.makeWrapper.
Behavior:
- Wraps all variants in
config.wrapperVariants. - Variants with
enable = falseare excluded. - Wraps the paths at
config.wrapperVariants.*.wrapperPaths.input - Outputs to
config.wrapperVariants.*.wrapperPaths.placeholder
Returns: A string containing build instructions to append to a derivation.
It also takes as an argument wrapperImplementation
You may define a function that receives config, wlib, and arguments from callPackage
and returns a string of build instructions, that follows similar behavior.
You may use the other functions in wlib.makeWrapper to help with this.
- structured function argument
-
pkgs-
Function argument
callPackage-
Function argument
config-
Function argument
wrapperImplementation-
Function argument
wlib.makeWrapper.wrapVariant
Generates build instructions for wrapping a single variant.
Usage:
wlib.makeWrapper.wrapVariant {
inherit config;
inherit (pkgs) callPackage; # or `inherit pkgs`;
name = "attribute";
};
Arguments:
pkgs(set either this orcallPackage): Package set providingcallPackage.callPackage(set either this orpkgs): calls the wrapper builder.config(required): Configuration attribute set.wrapperImplementation(optional): Path or function for the wrapper implementation.name(required): String name of a variant attribute inconfig.wrapperVariants.
Requirements on config:
- Must define
wrapperPaths.input,wrapperPaths.placeholder,wrapperPaths.relDir,outputName. - May include options from
wlib.modules.makeWrapper.
Behavior:
- Wraps only the specified variant.
- Asserts that
nameis a string. - If the selected variant has
enable = false, it is excluded. - Wraps the path at
config.wrapperVariants.${name}.wrapperPaths.input - Outputs to
config.wrapperVariants.${name}.wrapperPaths.placeholder
Returns: A string containing build instructions to append to a derivation.
It also takes as an argument wrapperImplementation
You may define a function that receives config, wlib, and arguments from callPackage
and returns a string of build instructions, that follows similar behavior.
You may use the other functions in wlib.makeWrapper to help with this.
- structured function argument
-
pkgs-
Function argument
callPackage-
Function argument
config-
Function argument
wrapperImplementation-
Function argument
name-
Function argument
wlib.makeWrapper.aggregateSingleOptionSet
Aggregates a single wrapper option set (either the top-level config
or one of the entries from config.wrapperVariants) into a unified
DAG-like list (DAL).
Usage:
wlib.makeWrapper.aggregateSingleOptionSet {
inherit config;
sortResult = true; # optional
};
Arguments:
config(required): An attribute set containing wrapper options. This may be the top-level wrapper configuration or a single variant’s option set.sortResult(optional, default:true): Whether to sort the resulting DAL usingwlib.dag.unwrapSort "makeWrapper".
Behavior:
- Collects the following wrapper option categories from
config:- unsetVar
- env
- envDefault
- prefixVar
- suffixVar
- prefixContent
- suffixContent
- chdir
- runShell
- flags
- addFlag
- appendFlag
- Normalizes each entry into a consistent structure containing:
type— the originating option categorydata— primary valuebefore/after/name— DAG sorting valuesesc-fn— not yet applied, may be null.value— original value- 3 more which are only present for some types:
sep/ifs—flagsoption-specific metadata (only included fortype == flags)attr-name— (on attribute-style options) original attribute name (can’t be overriden from within the spec)
- Attribute-based option sets (e.g.
env,flags) are converted into lists with their attribute names preserved. - If
sortResult = true, the combined list is then sorted according to DAG ordering rules viawlib.dag.unwrapSort.
Returns:
A list (DAL) of normalized option entries suitable for further
processing (e.g., splitting with splitDal or transforming with
fixArgs).
wlib.makeWrapper.splitDal
splitDal receives the dal as returned by aggregateSingleOptionSet and splits it into 2 lists, args and other.
It returns a set with args and other attributes, containing the same format of items as aggregateSingleOptionSet returns.
It puts all type == "flags", "addFlag", or "appendFlag" into args, and anything else into other.
args are almost always necessarily separate from the way anything else gets set, so a helper exists to separate them.
DAL-
Function argument
wlib.makeWrapper.fixArgs
Normalizes and resolves argument-related entries from a DAL into
concrete addFlag and appendFlag lists.
Usage:
wlib.makeWrapper.fixArgs {
sep = "="; # optional default separator
ifs = ","; # optional default inner-field separator
} argsDAL;
Arguments:
- 1st argument, a set with:
sep(optional, default:null): Default separator used when aflagsentry does not define its ownsep. If null, flags and values may be emitted as separate arguments depending on configuration.ifs(optional, default:null): Default inner-field separator used when aflagsentry does not define its ownifsand the value is a list.fixPreFlagSort(optional, default:true): Sorts the flags and addFlag values again after concatenating them, thus ensuring that it all still works like 1 DAL.
- 2nd argument (required):
A list of DAL entries, typically the
argsattribute returned bysplitDal, but may also be the full DAL.
Behavior:
- Identifies entries of type:
- “flags”
- “addFlag”
- “appendFlag”
- Converts all
"flags"entries into"addFlag"entries. - For each
"flags"entry:- Uses entry-specific
sepandifsif defined. - Otherwise falls back to the provided
sepandifsoptions.
- Uses entry-specific
- Handles flag value forms:
- Boolean flags (
true→ standalone flag,false/null → omitted) - Single scalar values
- Lists of values
- Boolean flags (
- Applies separator logic:
- If both
sepandifsare set and the value is a list, emits a single argument with joined values. - If
sepis set butifsis null, emits one argument per list element using the separator. - If
sepis null andifsis set, emits the flag name followed by a joined value string. - If both are null, emits flag and value(s) as separate arguments.
- If both
- Preserves existing
"addFlag"and"appendFlag"entries.
Returns: An attribute set containing:
{
addFlag = [ ... ]; # fully expanded and converted flags
appendFlag = [ ... ]; # append-style flag entries
}
Intended to be called after splitDal and before final wrapper
command generation.