wlib.modules.constructFiles
modules/constructFiles
This module is made possible by: birdee
Adds a constructFiles option that allows for easier creation of generated files in which placeholders such as ${placeholder "out"} work
From inside the module, you can
config.constructFiles.<name> = {
content = "some file content";
relPath = "some/path";
};
# you can get the resulting placeholder path with config.constructFiles.<name>.path
It also provides a read-only config value that allows the placeholder file location to be easily accessible outside of the derivation.
In addition, on the resulting package, all the values in config are accessible via passthru.configuration
This means you can yourWrappedPackage.configuration.constructFiles.<name>.outPath to get the final path to it from outside of the wrapper module,
without having to worry about making sure placeholders resolve correctly yourself.
Note, that will not work inside the module. Inside the module, you will want to use config.constructFiles.<name>.path.
Also note that attribute sets with .outPath in them can be directly interpolated.
Outside the module, you can also get the path with "${yourWrappedPackage.configuration.constructFiles.<name>}"
Imported by wlib.modules.default
constructFiles
An option for creating files with content of arbitrary length in the final wrapper derivation,
in which the nix placeholders like ${placeholder "out"} can be used
Type: attribute set of (submodule)
Default:
{ }
Declared by:
constructFiles.<name>.builder
the command used to build the file.
Will be placed inside a bash function, with $1 as the input file and $2 as the output file
Type: string
Default:
"cp \"$1\" \"$2\""
Declared by:
constructFiles.<name>.content
The content for the file to be added to the final derivation
Type: strings concatenated with “\n”
Default:
""
Declared by:
constructFiles.<name>.key
The attribute to add the file contents to on the final derivation
If you get an error like “config.jsonPath: invalid variable name”, then that means you should set this value to something which is a valid shell variable name.
Type: non-empty line
Default:
"‹name›"
Declared by:
constructFiles.<name>.outPath
The path to the output file available from outside of the wrapper module
Type: (read-only) string
Declared by:
constructFiles.<name>.output
The output the generated file will be created in.
Type: non-empty line
Default:
"out"
Declared by:
constructFiles.<name>.passAsContent
This option controls the value passed as $1 to the .builder command
If false, $1 will contain the path to the input file
If true, $1 will contain the content of the input file
It is recommended to use true when config.drv.__structuredAttrs = true
and false otherwise for performance,
unless you specifically need one or the other for your .builder command.
Type: boolean
Default:
false
Declared by:
constructFiles.<name>.path
The path to the output file available from inside of the wrapper module
Type: (read-only) string
Declared by:
constructFiles.<name>.relPath
relative output path within the named output to create the file (no leading slash)
Type: string
Declared by: