9 Creates a patch that replaces every instantiation of GSettings in a C project
10 with a code that loads a GSettings schema from a hardcoded path.
12 This is useful so that libraries can find schemas even though Nix lacks
13 a standard location like /usr/share, where GSettings system could look for schemas.
14 The derivation is is somewhat dependency-heavy so it is best used as part of an update script.
16 For each schema id referenced in the source code (e.g. org.gnome.evolution),
17 a variable name such as `EVOLUTION` must be provided.
18 It will end up in the generated patch as `@EVOLUTION@` placeholder, which should be replaced at build time
19 with a path to the directory containing a `gschemas.compiled` file that includes the schema.
23 - `src`: source to generate the patch for.
25 - `schemaIdToVariableMapping`: attrset assigning schema ids to variable names.
26 All used schemas must be listed.
28 For example, `{ "org.gnome.evolution" = "EVOLUTION_SCHEMA_PATH"; }`
29 hardcodes looking for `org.gnome.evolution` into `@EVOLUTION_SCHEMA_PATH@`.
31 - `patches`: A list of patches to apply before generating the patch.
35 hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
36 inherit (finalAttrs) src;
37 schemaIdToVariableMapping = {
45 updatePatch = _experimental-update-script-combinators.copyAttrOutputToFile "evolution-ews.hardcodeGsettingsPatch" ./hardcode-gsettings.patch;
47 _experimental-update-script-combinators.sequence [
57 schemaIdToVariableMapping,
61 "hardcode-gsettings.patch"
67 python3 # For patch script
72 cd "''${sourceRoot:-.}"
75 cp ${builtins.toFile "glib-schema-to-var.json" (builtins.toJSON schemaIdToVariableMapping)} ./glib-schema-to-var.json
78 spatch --sp-file "${./hardcode-gsettings.cocci}" --dir . --in-place