Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glib: Add variable for overriding schemas #31683

Merged
merged 2 commits into from Nov 27, 2017

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Nov 15, 2017

This is a part of GNOME 3.26 update. I would like to get input from glib maintainers (@lovek323, @raskin) & co.

I assume we prefer introducing custom enviroment variable to blocking an existing one? Though, if we used the existing one, user could always override it, only losing the defaults from NixOS module.

Motivation for this change

For some reason, the GNOME 3.26 update broke the overrides. It turns out the overrides now need to come before the overridden schemas in the XDG_DATA_DIRS variable. This is not possible in general due to applications prefixing the variable (e.g. in wrapGAppsHook).

To fix this, a new environment variable NIX_GSETTINGS_OVERRIDES_DIR was introduced. It has greater priority than XDG_DATA_DIRS but lower than GSETTINGS_SCHEMA_DIR. A separate variable was chosen in order not to block the built-in one for users.

Things done

I tested the module with GSETTINGS_SCHEMA_DIR variable, which is basically the same. Will test with the proper one once it builds.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

For some reason, the GNOME 3.26 update broke the overrides. It turns
out the overrides now need to come before the overriden schemas in the
XDG_DATA_DIRS variable. This is not possible in general due to applications
prefixing the variable (e.g. in wrapGAppsHook).

To fix this, a new environment variable NIX_GSETTINGS_OVERRIDES_DIR
was introduced. It has greater priority than XDG_DATA_DIRS but lower
than GSETTINGS_SCHEMA_DIR. A separate variable was chosen in order not
to block the built-in one for users.
For some reason, the GNOME 3.26 update broke the overrides. It turns
out the overrides now need to come before the overriden schemas in the
XDG_DATA_DIRS variable. This is not possible in general due to applications
prefixing the variable (e.g. in wrapGAppsHook).

To fix this, a new environment variable NIX_GSETTINGS_OVERRIDES_DIR
was introduced. It has greater priority than XDG_DATA_DIRS but lower
than GSETTINGS_SCHEMA_DIR. A separate variable was chosen in order not
to block the built-in one for users.
@grahamc
Copy link
Member

grahamc commented Nov 15, 2017

Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(57) "Estimating rebuild amount by counting changed Hydra jobs."
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [1]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(155) "error: while evaluating anonymous function at /tmp/nix-rebuild-amount-YfwaDe6R:13:12, called from /tmp/nix-rebuild-amount-ZGmw0xJG/lib/attrsets.nix:199:52:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [2]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(111) "while evaluating the attribute ‘x86_64-darwin’ at /tmp/nix-rebuild-amount-ZGmw0xJG/lib/attrsets.nix:185:41:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [3]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(178) "while evaluating anonymous function at /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/top-level/release-lib.nix:66:6, called from /tmp/nix-rebuild-amount-ZGmw0xJG/lib/attrsets.nix:282:43:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [4]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(180) "while evaluating ‘hydraJob’ at /tmp/nix-rebuild-amount-ZGmw0xJG/lib/customisation.nix:157:14, called from /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/top-level/release-lib.nix:66:14:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [5]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(110) "while evaluating the attribute ‘drvPath’ at /tmp/nix-rebuild-amount-ZGmw0xJG/lib/customisation.nix:174:13:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [6]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(110) "while evaluating the attribute ‘drvPath’ at /tmp/nix-rebuild-amount-ZGmw0xJG/lib/customisation.nix:145:40:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [7]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(166) "while evaluating the attribute ‘cc’ of the derivation ‘clang-wrapper-3.4.2’ at /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [8]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(167) "while evaluating the attribute ‘postInstall’ of the derivation ‘clang-3.4.2’ at /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [9]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(165) "while evaluating the attribute ‘cmakeFlags’ of the derivation ‘llvm-3.4.2’ at /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [10]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(135) "while evaluating the derivation attribute ‘name’ at /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [11]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(119) "attribute ‘version’ missing, at /tmp/nix-rebuild-amount-ZGmw0xJG/pkgs/development/libraries/libbfd/default.nix:6:26"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [12]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(155) "error: while evaluating anonymous function at /tmp/nix-rebuild-amount-MyLlifBZ:13:12, called from /tmp/nix-rebuild-amount-EXW3wJHS/lib/attrsets.nix:199:52:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [13]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(111) "while evaluating the attribute ‘x86_64-darwin’ at /tmp/nix-rebuild-amount-EXW3wJHS/lib/attrsets.nix:185:41:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [14]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(178) "while evaluating anonymous function at /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/top-level/release-lib.nix:66:6, called from /tmp/nix-rebuild-amount-EXW3wJHS/lib/attrsets.nix:282:43:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [15]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(180) "while evaluating ‘hydraJob’ at /tmp/nix-rebuild-amount-EXW3wJHS/lib/customisation.nix:157:14, called from /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/top-level/release-lib.nix:66:14:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [16]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(110) "while evaluating the attribute ‘drvPath’ at /tmp/nix-rebuild-amount-EXW3wJHS/lib/customisation.nix:174:13:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [17]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(110) "while evaluating the attribute ‘drvPath’ at /tmp/nix-rebuild-amount-EXW3wJHS/lib/customisation.nix:145:40:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [18]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(166) "while evaluating the attribute ‘cc’ of the derivation ‘clang-wrapper-3.4.2’ at /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [19]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(167) "while evaluating the attribute ‘postInstall’ of the derivation ‘clang-3.4.2’ at /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [20]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(165) "while evaluating the attribute ‘cmakeFlags’ of the derivation ‘llvm-3.4.2’ at /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [21]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(135) "while evaluating the derivation attribute ‘name’ at /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/stdenv/generic/make-derivation.nix:98:11:"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   [22]=>
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]:   string(119) "attribute ‘version’ missing, at /tmp/nix-rebuild-amount-EXW3wJHS/pkgs/development/libraries/libbfd/default.nix:6:26"
Nov 15 14:30:17 zoidberg grahamcofborg-mass-rebuilder-start[29678]: }

I'll have to look in to why the eval check thinks this is OK, but the estimator thinks it isn't. Also, I need to fix the estimator to exit non-zero on eval errors :)


+ if ((path = g_getenv ("NIX_GSETTINGS_OVERRIDES_DIR")) != NULL)
+ try_prepend_dir (path);
+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you call it overrides, shouldn't it be prepended last, to have maximal priority? And if these are just additions, maybe call them NIX_EXTRA_GSETTINGS_DIR or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed the GSETTINGS_SCHEMA_DIR is for debugging, which is why I made kept it the highest priority. I named it overrides since its purpose is to load defaults overridden by the gnome3 NixOS module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect this option to be used to add and not override anything, so I would use something like NIX_GSETTINGS_SCHEMA_DIR.

I am not convinced, but I agree it is not worth further bikeshedding. The change looks good in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, glib acts like if it traversed all the directories on the list and added the default values for each key described in the directory to a dictionary, but did not override the keys already in the dictionary – basically the first match is used, hence the override.

@7c6f434c
Copy link
Member

@grahamc are you sure the two checks were not done w.r.t. different master positions?

@7c6f434c
Copy link
Member

@vcunat @lovek323 any objections? I think this is OK for staging.

@jtojnar jtojnar added this to Ready in GNOME Nov 25, 2017
@@ -150,7 +150,7 @@ in {
export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${mimeAppsList}/share

# Override gsettings-desktop-schema
export XDG_DATA_DIRS=${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides''${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS
export NIX_GSETTINGS_OVERRIDES_DIR=${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be a use case where $NIX_GSETTINGS_OVERRIDES_DIR was set already before this command?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, that can be amended later without a larger rebuild.

@vcunat vcunat merged commit 510737c into NixOS:staging Nov 27, 2017
GNOME automation moved this from Ready to Done Nov 27, 2017
@jtojnar jtojnar deleted the schema-override-variable branch November 27, 2017 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
GNOME
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants