makeHardcodeGsettingsPatch: Improve docs
- Describe arguments and usage in more detail. - Use finalAttrs in example. - Use schema id, not path. - Schema id is not what is replaced.
This commit is contained in:
parent
81283429b7
commit
6f695f3d92
2 changed files with 40 additions and 21 deletions
|
@ -6,15 +6,35 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Can be used as part of an update script to automatically create a patch
|
Creates a patch that replaces every instantiation of GSettings in a C project
|
||||||
hardcoding the path of all GSettings schemas in C code.
|
with a code that loads a GSettings schema from a hardcoded path.
|
||||||
For example:
|
|
||||||
passthru = {
|
This is useful so that libraries can find schemas even though Nix lacks
|
||||||
hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
|
a standard location like /usr/share, where GSettings system could look for schemas.
|
||||||
inherit src;
|
The derivation is is somewhat dependency-heavy so it is best used as part of an update script.
|
||||||
schemaIdToVariableMapping = {
|
|
||||||
...
|
For each schema id referenced in the source code (e.g. org.gnome.evolution),
|
||||||
};
|
a variable name such as `EVOLUTION` must be provided.
|
||||||
|
It will end up in the generated patch as `@EVOLUTION@` placeholder, which should be replaced at build time
|
||||||
|
with a path to the directory containing a `gschemas.compiled` file that includes the schema.
|
||||||
|
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
- `src`: source to generate the patch for.
|
||||||
|
|
||||||
|
- `schemaIdToVariableMapping`: attrset assigning schema ids to variable names.
|
||||||
|
All used schemas must be listed.
|
||||||
|
|
||||||
|
For example, `{ "org.gnome.evolution" = "EVOLUTION_SCHEMA_PATH"; }`
|
||||||
|
hardcodes looking for `org.gnome.evolution` into `@EVOLUTION_SCHEMA_PATH@`.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
passthru = {
|
||||||
|
hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
|
||||||
|
inherit (finalAttrs) src;
|
||||||
|
schemaIdToVariableMapping = {
|
||||||
|
...
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
updateScript =
|
updateScript =
|
||||||
|
@ -26,12 +46,8 @@
|
||||||
updateSource
|
updateSource
|
||||||
updatePatch
|
updatePatch
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
takes as input a mapping from schema path to variable name.
|
|
||||||
For example `{ "org.gnome.evolution" = "EVOLUTION_SCHEMA_PATH"; }`
|
|
||||||
hardcodes looking for `org.gnome.evolution` into `@EVOLUTION_SCHEMA_PATH@`.
|
|
||||||
All schemas must be listed.
|
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
src,
|
src,
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
/**
|
/**
|
||||||
* Since Nix does not have a standard location like /usr/share,
|
* Since Nix does not have a standard location like /usr/share where GSettings system
|
||||||
* where GSettings system could look for schemas, we need to point the software to a correct location somehow.
|
* could look for schemas, we need to point the software to a correct location somehow.
|
||||||
* For executables, we handle this using wrappers but this is not an option for libraries like e-d-s.
|
* For executables, we handle this using wrappers but this is not an option for libraries like e-d-s.
|
||||||
* Instead, we hardcode the schema path when creating the settings.
|
* Instead, we patch the source code to look for the schema in a schema source
|
||||||
* A schema path (ie org.gnome.evolution) can be replaced by @EVOLUTION_SCHEMA_ID@
|
* through a hardcoded path to the schema.
|
||||||
* which is then replaced at build time by substituteAll.
|
*
|
||||||
* The mapping is provided in a json file ./glib-schema-to-var.json
|
* For each schema id referenced in the source code (e.g. org.gnome.evolution),
|
||||||
|
* a variable name such as `EVOLUTION` must be provided in the ./glib-schema-to-var.json JSON file.
|
||||||
|
* It will end up in the resulting patch as `@EVOLUTION@` placeholder, which should be replaced at build time
|
||||||
|
* with a path to the directory containing a `gschemas.compiled` file that includes the schema.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@initialize:python@
|
@initialize:python@
|
||||||
|
|
Loading…
Reference in a new issue