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.

+40 -21
+31 -15
pkgs/build-support/make-hardcode-gsettings-patch/default.nix
··· 6 }: 7 8 /* 9 - Can be used as part of an update script to automatically create a patch 10 - hardcoding the path of all GSettings schemas in C code. 11 - For example: 12 - passthru = { 13 - hardcodeGsettingsPatch = makeHardcodeGsettingsPatch { 14 - inherit src; 15 - schemaIdToVariableMapping = { 16 - ... 17 - }; 18 }; 19 20 updateScript = ··· 26 updateSource 27 updatePatch 28 ]; 29 - }; 30 - } 31 - takes as input a mapping from schema path to variable name. 32 - For example `{ "org.gnome.evolution" = "EVOLUTION_SCHEMA_PATH"; }` 33 - hardcodes looking for `org.gnome.evolution` into `@EVOLUTION_SCHEMA_PATH@`. 34 - All schemas must be listed. 35 */ 36 { 37 src,
··· 6 }: 7 8 /* 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. 11 + 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. 15 + 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. 20 + 21 + 22 + Arguments: 23 + - `src`: source to generate the patch for. 24 + 25 + - `schemaIdToVariableMapping`: attrset assigning schema ids to variable names. 26 + All used schemas must be listed. 27 + 28 + For example, `{ "org.gnome.evolution" = "EVOLUTION_SCHEMA_PATH"; }` 29 + hardcodes looking for `org.gnome.evolution` into `@EVOLUTION_SCHEMA_PATH@`. 30 + 31 + Example: 32 + passthru = { 33 + hardcodeGsettingsPatch = makeHardcodeGsettingsPatch { 34 + inherit (finalAttrs) src; 35 + schemaIdToVariableMapping = { 36 + ... 37 + }; 38 }; 39 40 updateScript = ··· 46 updateSource 47 updatePatch 48 ]; 49 + }; 50 + } 51 */ 52 { 53 src,
+9 -6
pkgs/build-support/make-hardcode-gsettings-patch/hardcode-gsettings.cocci
··· 1 /** 2 - * Since Nix does not have a standard location like /usr/share, 3 - * where GSettings system could look for schemas, we need to point the software to a correct location somehow. 4 * For executables, we handle this using wrappers but this is not an option for libraries like e-d-s. 5 - * Instead, we hardcode the schema path when creating the settings. 6 - * A schema path (ie org.gnome.evolution) can be replaced by @EVOLUTION_SCHEMA_ID@ 7 - * which is then replaced at build time by substituteAll. 8 - * The mapping is provided in a json file ./glib-schema-to-var.json 9 */ 10 11 @initialize:python@
··· 1 /** 2 + * Since Nix does not have a standard location like /usr/share where GSettings system 3 + * could look for schemas, we need to point the software to a correct location somehow. 4 * For executables, we handle this using wrappers but this is not an option for libraries like e-d-s. 5 + * Instead, we patch the source code to look for the schema in a schema source 6 + * through a hardcoded path to the schema. 7 + * 8 + * For each schema id referenced in the source code (e.g. org.gnome.evolution), 9 + * a variable name such as `EVOLUTION` must be provided in the ./glib-schema-to-var.json JSON file. 10 + * It will end up in the resulting patch as `@EVOLUTION@` placeholder, which should be replaced at build time 11 + * with a path to the directory containing a `gschemas.compiled` file that includes the schema. 12 */ 13 14 @initialize:python@