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

package GNOME Builder #44217

Merged
merged 11 commits into from Aug 1, 2018
Merged

package GNOME Builder #44217

merged 11 commits into from Aug 1, 2018

Conversation

jameysharp
Copy link
Contributor

Motivation for this change

This is my second try, replacing #44187, after @jtojnar pointed out there was a prior attempt in #33270 and that my previous attempt broke a bunch of other packages.

After very carefully reading 1dba3c0, #37381, and the commit history for pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch, I finally figured out that I just needed to patch src/libide/meson.build to replace pkglibdir with pkglibdir_abs instead of messing around with changes to the gobjectIntrospection package. So this PR is based against master instead of staging, since it only introduces new packages.

This build works okay for me except that Builder seems to carefully clear the environment before running build steps, which is a behavior that I think needs to be patched somehow. I'm not sure how yet.

I think this PR is better in some ways than #33270; it's possible some hybrid of the two would be best. In particular, I'm more fond of my approach of passing the Nix value python3.libPrefix (which currently evaluates to "python3.6") in as a Meson config option rather than substituting python3.sitePackages into a patch. One advantage is that I think my patch could be accepted upstream, possibly with whitespace changes. Also it doesn't run a Python command whose result it then ignores.

#33270 also patched all the plugins to use hard-coded paths, which is a very invasive patch, and difficult to verify that it's correct. I see what problem that exists to solve, but I'm wondering if there's an easier way... If that's the best we can do, it's probably not hard to apply that patch to my branch too.

My suspicion is, though, that upstream Builder should do a better job of handling per-project environment variables, possibly by supporting tools like https://direnv.net/ (or nix-shell directly). Then if you want to use a particular plugin with a particular project, you'd include that plugin's dependencies in your project's environment. That should help keep the closure for Builder be not quite so huge...

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@jameysharp
Copy link
Contributor Author

Since @jtojnar cherry-picked the other version of jsonrpc-glib and template-glib onto master today, I've rebased this PR dropping my commits that packaged those libraries. I had to make a minor fix to my gnome-builder packaging as a result but this version works just as well for me too.

@jtojnar
Copy link
Contributor

jtojnar commented Jul 30, 2018

I finally figured out that I just needed to patch src/libide/meson.build to replace pkglibdir with pkglibdir_abs instead of messing around with changes to the gobjectIntrospection package.

Sounds good.

This build works okay for me except that Builder seems to carefully clear the environment before running build steps, which is a behavior that I think needs to be patched somehow. I'm not sure how yet.

What do you mean?

In particular, I'm more fond of my approach of passing the Nix value python3.libPrefix (which currently evaluates to "python3.6") in as a Meson config option rather than substituting python3.sitePackages into a patch. One advantage is that I think my patch could be accepted upstream, possibly with whitespace changes. Also it doesn't run a Python command whose result it then ignores.

I am all for it if upstream accepts it.

#33270 also patched all the plugins to use hard-coded paths, which is a very invasive patch, and difficult to verify that it's correct. I see what problem that exists to solve, but I'm wondering if there's an easier way... If that's the best we can do, it's probably not hard to apply that patch to my branch too.

I like to make everything explicit in patches because they make it easier to track changes but I agree that there are downsides. Instead of patch, we could also use something like gappsWrapperArgs+=(--prefix PATH : "${stdenv.lib.makeBinPath [ meson ninja … ]}").

My suspicion is, though, that upstream Builder should do a better job of handling per-project environment variables, possibly by supporting tools like https://direnv.net/ (or nix-shell directly). Then if you want to use a particular plugin with a particular project, you'd include that plugin's dependencies in your project's environment. That should help keep the closure for Builder be not quite so huge...

We could make the binpath overridable and have a gnome-builderLight package that would set it to empty list.

sha256 = "0ibb74jlyrl5f6rj1b74196zfg2qaf870lxgi76qzpkgwq0iya05";
};

buildInputs = [
Copy link
Contributor

Choose a reason for hiding this comment

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

The dependencies used for build should go to nativeBuildInputs.

];

prePatch = ''
sed -i 's@/usr/bin/env python3@${python3}/bin/python3@g' build-aux/meson/post_install.py
Copy link
Contributor

Choose a reason for hiding this comment

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

We have patchShebangs function for this, see #33270

meta = with stdenv.lib; {
description = "An IDE for writing GNOME-based software";
homepage = https://wiki.gnome.org/Apps/Builder;
license = licenses.gpl3;
Copy link
Contributor

Choose a reason for hiding this comment

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

preFixup = ''
buildPythonPath "$out $pythonPath"
gappsWrapperArgs+=(
--prefix PATH : "$program_PATH"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what $program_PATH is for, should not fixing shebangs be enough?

meta = with stdenv.lib; {
description = "An IDE for writing GNOME-based software";
homepage = https://wiki.gnome.org/Apps/Builder;
license = licenses.gpl3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add maintainers = gnome3.maintainers

mesonFlags = [
"-Dpython_libprefix=${python3.libPrefix}"
"-Dwith_clang=false"
"-Dwith_flatpak=false"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is not flatpak enabled?

'';

patches = [
./python-libprefix.patch
./flatpak-deps.patch
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you send this upstream and add a comment with a link here?

@jameysharp
Copy link
Contributor Author

I've just submitted some patches upstream toward this effort, and we'll see what the maintainers think:

https://gitlab.gnome.org/GNOME/gnome-builder/merge_requests/86

I've pushed an additional commit to this PR that I think addresses all your review comments, although I'm still not sure how to tell whether a dependency is only needed at build-time or also at run-time, so I might still have the buildInputs and nativeBuildInputs split incorrectly. Anyway, feel free to squash the branch if you want.

I'd disabled flatpak because it didn't build (and I'll point out that #33270 also disabled flatpak) but it turns out a minor patch fixes that, so it's enabled now. I've added that to my upstream merge request too.

The problem I observed with the environment getting cleared is that when I have a project open in Builder, clicking the "Build" button fails because it can't find programs like pkg-config. But opening a terminal inside Builder and running the same build command succeeds. So I think Builder sets up the environment differently for build commands that it runs. And in fact there's a clear-env property in the Builder implementation that among other things sets PATH to whatever was chosen as SAFE_PATH at configure time, which I believe is winding up as /bin:/usr/bin. But I haven't traced things through carefully enough to prove that's what's going on or figure out what to do about it.

I've been talking with Christian Hergert about some of the issues I've been having, and regarding the build environment problem, he suggests:

implement an IdeRuntimeProvider that lets us specify those "containers of tools" with some description file. Then you'd set your projects runtime to that instead of "Host".

I think that may be something I can tackle...

pythonPath = with python3Packages; requiredPythonModules [ pygobject3 ];

preFixup = ''
buildPythonPath "$out $pythonPath"
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder what the difference between buildPythonPath and python.withPackages is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#33270 used with python3.pkgs; makePythonPath instead of my combination of with python3Packages; requiredPythonModules and the buildPythonPath shell function. My way is probably worse but I had thought I needed the $program_PATH that it built for me.

There is one tricky thing though that might force keeping this approach, I guess? We need the Python import path to include $out/lib/python*/site-packages, not just the site-packages directories from other Python packages, so that the gi/overrides modules that gnome-builder installs are available when it runs.

I'm not sure if there's any way to include the current derivation's $out in its own PYTHONPATH except by passing "$out" to buildPythonPath...?

# We want to find the subdirectory to install our override into:
+python_libprefix = get_option('python_libprefix')
+if python_libprefix != ''
+ pygobject_override_dir = join_paths(get_option('libdir'), python_libprefix, 'site_packages', 'gi', 'overrides')
Copy link
Contributor

Choose a reason for hiding this comment

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

site_packages should contain dash, not underscore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Um. That's true. Why did this work...?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, it did not for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. I guess the only plugin that actually needed gi/overrides/Ide.py was the jedi_plugin, and I ignored the error message from that because everything else was working fine. But getting the path correct fixes that error.

desktop-file-utils
];

buildInputs = [
Copy link
Contributor

Choose a reason for hiding this comment

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

You are missing hicolor-icon-theme, see #43926


appstream-glib
desktop-file-utils
];
Copy link
Contributor

Choose a reason for hiding this comment

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

Unlike #33270, this package does not make docs.

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 hadn't investigated what these were for, I just saw they were optional but not found so I added them. Looks like they aren't about documentation, they're just there to validate that various static files are correctly formatted. You're right, we don't need them at package-build time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that gtk-doc and the docbook deps were missing. appstream-glib is used during build for checking the generated flle: https://gitlab.gnome.org/GNOME/gnome-builder/blob/23e2dc8347d00c2d0d909809b9c965c84ba08752/data/meson.build#L28

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. But appstream-glib and desktop-file-utils are only used in tests, and with doCheck unspecified, we aren't actually running the tests, are we? I mean, maybe we should be, but the other PR didn't either. I'm going to try a build with doCheck = true...

Hmm, turns out desktop-file-utils is actually required by build-aux/meson/post_install.py as well, so I definitely can't remove that.

Anyway, I'm turning on the documentation building too. I didn't think it was particularly important since it's only documentation for gnome-builder's plugin API, but I guess that's worth having.

Should we have multiple outputs for this package? I can see value in some combination of 'lib', 'dev', and 'devdoc'...

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, maybe we should be, but the other PR didn't either.

Yes, if there are tests, we should try to enable them.

I didn't think it was particularly important since it's only documentation for gnome-builder's plugin API, but I guess that's worth having.

Yup, offline docs are useful for devhelp (if we figure out why it does not work).

Should we have multiple outputs for this package? I can see value in some combination of 'lib', 'dev', and 'devdoc'...

out and doc/devdoc make sense for apps. lib and dev only if the package contains a library that is expected to be a dependency of other packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Validating the appstream files requires connecting to the internet (?!) so that test will definitely fail under Nix, and we probably just shouldn't install appstream-glib. Several other tests fail with this message:

00:06:10.0290                           ide-application[ 26893]:  WARNING: Cannot enable Python 3 plugins: Typelib file for namespace 'Vte', version '2.91' not found

(I know that says it's only a warning, but it's the only output reported from the failing tests.)

I'm confused because gnome3.vte is already in buildInputs, and according to the test suite's dump of the environment for failing tests, GI_TYPELIB_PATH lists several other packages that are in buildInputs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Validating the appstream files requires connecting to the internet

Weird, it really should not. We have plenty of other apps that validate appstream files without any issues.

I'm confused because gnome3.vte is already in buildInputs, and according to the test suite's dump of the environment for failing tests, GI_TYPELIB_PATH lists several other packages that are in buildInputs.

Maybe it is some env clean-up again. Could you push the changes, I would like to take a look.

I also tried turning on the tests, but they don't work and I don't
understand why not.
@jameysharp
Copy link
Contributor Author

Hooray, my upstream merge request has been rebased and merged onto master! I think that was early enough to get in before the 3.30 release freeze, so hopefully those patches will be in the next stable release. But I don't actually understand the GNOME release cycle... 😅

The patches in this branch are now exactly the patches that are on master upstream, which I hope will make them easy to evaluate when upgrading.

I'm never quite sure when GitHub sends notifications, either. Did it tell you that I pushed my changes so far when you asked for them an hour ago, or should I have written a comment saying so...?

@jameysharp
Copy link
Contributor Author

Hah, it looks like neither this package nor #33270 actually managed to get the gtk-doc output into $out, even when it was built; we both should have had outputDevdoc = 'out'. Fixed now...

@jameysharp
Copy link
Contributor Author

Also the documentation totally didn't build correctly because it tried to get the Docbook DTDs from the internet since neither of us had pulled in docbook_xml_dtd_43 so it could use a local catalog instead.

And then once I fixed that, there was a locale problem in the Meson driver for gtkdoc.

Blech. But I can read the generated HTML documentation now, which is nice because the online copy is several major releases old.

@@ -73,6 +73,8 @@ in stdenv.mkDerivation {
webkitgtk
];

outputDevdoc = "out";
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just use devdoc output his is optional.

@jtojnar jtojnar mentioned this pull request Jul 31, 2018
13 tasks
@jtojnar
Copy link
Contributor

jtojnar commented Jul 31, 2018

I'm never quite sure when GitHub sends notifications, either. Did it tell you that I pushed my changes so far when you asked for them an hour ago, or should I have written a comment saying so...?

Simple build fixes are unaffected by the freezes: https://wiki.gnome.org/ReleasePlanning/Freezes

The patches in this branch are now exactly the patches that are on master upstream, which I hope will make them easy to evaluate when upgrading.

I would use fetchpatch then.

I'm never quite sure when GitHub sends notifications, either. Did it tell you that I pushed my changes so far when you asked for them an hour ago, or should I have written a comment saying so...?

I am not sure either, this time I received a notification but sometimes I do not. The difference seems to be that other projects use appstream-util validate command, whereas Builder uses appstream-util validate-relaxng. Ignoring it for now is probably the best choice of action.

These patches were merged to master so we can fetch them from the GNOME
GitLab instance now.
@jameysharp
Copy link
Contributor Author

Okay, as suggested I used fetchpatch and split out the separate devdoc output. As you said in the other pull request, I'm also "Not sure what else is missing". This is kind of usable as it stands now...

@@ -0,0 +1,29 @@
From 6d2edb1635465dc226bc7e05fd33c9ee456e2430 Mon Sep 17 00:00:00 2001
Copy link
Contributor

Choose a reason for hiding this comment

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

These patches can be removed.

done
'';

#doCheck = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment why this is disabled.


mesonFlags = [
"-Dpython_libprefix=${python3.libPrefix}"
"-Dwith_clang=false"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment why this is disabled.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 1, 2018

I tried running it with nix-shell -p gnome-builder autoconf clang clang-tools cmake ctags flatpak-builder gnome3.gjs gnumake indent meson packagekit pkgconfig python3 python3.pkgs.jedi python3.pkgs.lxml python3.pkgs.sphinx python3.pkgs.sphinx_rtd_theme rustup unzip which --run gnome-builder and it works, except for getting jedi not found, python auto-completion not possible.

Also, since we have decided to use it with nix-shell/direnv, comment explaining why it does not work from the get-go and redirecting users to one of these solutions should be added to the top of the file.

@jameysharp
Copy link
Contributor Author

Do you think the comment explaining why it doesn't work without a nix-shell should go in meta.longDescription, perhaps?

@jtojnar
Copy link
Contributor

jtojnar commented Aug 1, 2018

Some people prefer it there, as it it visible on the package list on the website. Other people grep nixpkgs repo and comment on the top is more convenient for them. There is not any preferrence as fair as I know.

@jameysharp
Copy link
Contributor Author

We could put the whole meta section at the top of the file and make both groups happy... 😁

Including a comment about the need for additional runtime dependencies.
@jameysharp
Copy link
Contributor Author

Okay, I've pushed a longDescription. I'm going to bed now, but I'll check in tomorrow if there's anything else you'd like me to change. Thank you for your help getting this package into shape!

@jtojnar
Copy link
Contributor

jtojnar commented Aug 1, 2018

I find having meta at top makes the expressions less clean and also it is non-standard.

@jameysharp
Copy link
Contributor Author

Do you mean having meta at the top of the file is non standard? Although I think there's actually a good argument for doing that, I wasn't seriously suggesting it. I left meta at the bottom as is normal elsewhere.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 1, 2018

Yep, that was I meant. I have seen it in an expression or two but it is highly irregular and consistency is probably more important.

license = licenses.gpl3Plus;
maintainers = gnome3.maintainers;
platforms = platforms.linux;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove the trailing space here?

@jtojnar
Copy link
Contributor

jtojnar commented Aug 1, 2018

Also, do you have any idea how to fix the jedi thing?

@jameysharp
Copy link
Contributor Author

Okay that took a lot of effort to track down, but the jedi thing is that nixpkgs has too new of a version of jedi for this version of gnome-builder. It should be fixed when gnome-builder 3.30 is released, as far as I can tell. Also, that version of gnome-builder will print the actual exception in addition to the "jedi not found" message, which would have made troubleshooting this a whole lot easier.

We could just disable building the jedi plugin with a comment that it can be re-enabled in 3.30, if you like?

(I also fixed the whitespace, thanks for pointing that out.)

@jtojnar jtojnar merged commit 0a12371 into NixOS:master Aug 1, 2018
@jameysharp
Copy link
Contributor Author

Thanks so much for merging this, @jtojnar!

By the way, I just discovered a one-line kludge that allows me to actually compile things with Builder, so long as my environment was set up correctly before I launched Builder:

--- a/src/libide/buildsystem/ide-build-pipeline.c
+++ b/src/libide/buildsystem/ide-build-pipeline.c
@@ -2773,7 +2773,7 @@ ide_build_pipeline_create_launcher (IdeBuildPipeline  *self,
     {
       IdeEnvironment *env = ide_configuration_get_environment (self->configuration);

-      ide_subprocess_launcher_set_clear_env (ret, TRUE);
+      ide_subprocess_launcher_set_clear_env (ret, FALSE);
       ide_subprocess_launcher_overlay_environment (ret, env);
       /* Always ignore V=1 from configurations */
       ide_subprocess_launcher_setenv (ret, "V", "0", TRUE);

I'm pretty sure they'll never take this patch upstream. I'm not even sure it's a good idea in Nix. But at least it highlights precisely where I've been having trouble.

I'll still see if I can implement Christian Hergert's suggestion, of writing a plugin that allows a project to set its own environment, whether that's via nix-shell or direnv or whatever.

@jtojnar jtojnar mentioned this pull request Sep 13, 2018
9 tasks
@jameysharp jameysharp deleted the gnome-builder-v2 branch July 8, 2019 18:39
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-install-gnome-sdk-dev-dependencies/5599/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants