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

packagekit: update to flakes branch #94055

Merged
merged 1 commit into from Feb 9, 2022

Conversation

matthewbauer
Copy link
Member

@matthewbauer matthewbauer commented Jul 28, 2020

This is most of the way toward
#21230. We will need a new Nix
release and some more extensive testing before merging it into
PackageKit.

Upstream branch: PackageKit/PackageKit#414

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/try-out-the-updated-nix-backend-in-packagekit-with-flakes-support/8343/1

@worldofpeace
Copy link
Contributor

worldofpeace commented Jul 28, 2020

I'm noticing something inside packagekit lib/gtk-3.0/modules/libpk-gtk-module.so.
I think in order for this to be used we need to add this into GTK3_MODULES environment variable.

@worldofpeace
Copy link
Contributor

worldofpeace commented Jul 28, 2020

I've tried it in a VM.

pkcon get-packages
pkcon install celluloid
celluloid

I was able to start celluloid.

I noticed two things atm:

  1. packages under like gnome3. or pantheon. attributes don't show up in search results (so you can't install them)
  2. removing packages seems broken?
    Needs to be looked into deeper, but it seems to show a success to remove a package, but nix-env -q would show it still installed.

Haven't tried gui's like gnome-software yet, though, I'm betting they will be broken.

Will try to get good backtraces when I get to test it more and probably run into some crashes.

@worldofpeace
Copy link
Contributor

Unrelated nit in the PR, packagekit.nix vendorConf could have a let url = "https://github.com/NixOS/nixpkgs"; so we don't repeat the same string a bunch of times.

@matthewbauer
Copy link
Member Author

  1. packages under like gnome3. or pantheon. attributes don't show up in search results (so you can't install them)

Yeah the recurseForDerivations feature is missing. It's easy to add though since nix search supports it as well.

  1. removing packages seems broken?

I had install / remove working, but there may be an issue if the thing installed is a different path than what's in nixpkgs. I'll take a look.

@matthewbauer
Copy link
Member Author

Haven't tried gui's like gnome-software yet, though, I'm betting they will be broken.

I just tried gnome-packagekit, and it works fairly well. There's probably some polishing that could make it a bit better, but it can do basic search & install.

As for GNOME Software, we need indexing of metainfo to get the prettier displays (#15932). I'm not sure if it shows anything without that.

@wmertens
Copy link
Contributor

wmertens commented Mar 9, 2021

I'm curious what the state of this is, it's not obvious from looking at the various issues. It seems to me that this is a great boon for increasing the NixOS userbase?

@matthewbauer
Copy link
Member Author

I'm curious what the state of this is, it's not obvious from looking at the various issues. It seems to me that this is a great boon for increasing the NixOS userbase?

Yep! The main thing holding it back is that Nix with caching support is not officially released. I'm hoping that happens soon and we can start merging this and the packagekit PR.

@davidak davidak mentioned this pull request Sep 1, 2021
5 tasks
@stale
Copy link

stale bot commented Sep 6, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 6, 2021
@lapp0
Copy link

lapp0 commented Nov 21, 2021

@matthewbauer with nix 2.4 released, should this PR process continue? I'd like to have this feature.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 21, 2021
@matthewbauer matthewbauer changed the title [wip] packagekit: update to flakes branch packagekit: update to flakes branch Feb 8, 2022
@matthewbauer matthewbauer marked this pull request as ready for review February 8, 2022 03:21
@matthewbauer
Copy link
Member Author

@worldofpeace Care to review again? It should be ready to go now that the work is merged upstream.

@davidak
Copy link
Member

davidak commented Feb 8, 2022

worldofpeace left the project. maybe someone else can review it?

i don't see any obvious issue, but i don't know much about packagekit

can it already be tested? what should work after this PR?

pkgs/tools/package-management/packagekit/default.nix Outdated Show resolved Hide resolved
pkgs/tools/package-management/packagekit/default.nix Outdated Show resolved Hide resolved
pkgs/tools/package-management/packagekit/default.nix Outdated Show resolved Hide resolved
pkgs/tools/package-management/packagekit/default.nix Outdated Show resolved Hide resolved
"--enable-introspection"
"--disable-offline-update"
"--localstatedir=/var"
"--sysconfdir=/etc"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am afraid PackageKit will use configs from ${out}/etc without this. We might either patch the runtime paths (example), or hack around this using DESTDIR (example).

Copy link
Contributor

Choose a reason for hiding this comment

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

should it use configs from /etc? Where should the state be stored?

I can't figure out how it does installs, does it manage the user profile via nix-env?

Copy link
Contributor

Choose a reason for hiding this comment

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

State should go to localstatedir (which suffers from the same issue as sysconfdir). Though I would expect it to be mostly stateless (maybe there are some caches).

@jtojnar
Copy link
Contributor

jtojnar commented Feb 9, 2022

Tried it in a GNOME VM

--- a/nixos/modules/services/x11/desktop-managers/gnome.nix
+++ b/nixos/modules/services/x11/desktop-managers/gnome.nix
@@ -532,9 +532,6 @@ in
             simple-scan
             totem
             yelp
-          ] ++ lib.optionals config.services.flatpak.enable [
-            # Since PackageKit Nix support is not there yet,
-            # only install gnome-software if flatpak is enabled.
             gnome-software
           ])
           config.environment.gnome.excludePackages;

and got a crash on startup (probably triggered by GNOME Software):

Feb 08 23:54:14 nixos PackageKit[1643]: uid 1000 is trying to obtain org.freedesktop.packagekit.system-sources-refresh auth (only_trusted:0)
Feb 08 23:54:14 nixos PackageKit[1643]: uid 1000 obtained auth for org.freedesktop.packagekit.system-sources-refresh
Feb 08 23:54:14 nixos packagekitd[1643]: **
Feb 08 23:54:14 nixos packagekitd[1643]: PackageKit-Nix:ERROR:../backends/nix/pk-backend-nix.cc:244:void nix_search_thread(PkBackendJob*, GVariant*, gpointer): code should not be reached
Feb 08 23:54:14 nixos packagekitd[1643]: Bail out! PackageKit-Nix:ERROR:../backends/nix/pk-backend-nix.cc:244:void nix_search_thread(PkBackendJob*, GVariant*, gpointer): code should not be reached
Feb 08 23:54:14 nixos systemd[1]: Started Process Core Dump (PID 1702/UID 0).
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007f0e4394c533 in __GI_abort () at abort.c:79
#2  0x00007f0e43fc7ddc in g_assertion_message (domain=<optimized out>, file=0x7f0e419940f0 "../backends/nix/pk-backend-nix.cc", line=<optimized out>, func=<optimized out>, message=<optimized out>)
    at ../glib/gtestutils.c:3223
#3  0x00007f0e44026f3b in g_assertion_message_expr (domain=domain@entry=0x7f0e41994125 "PackageKit-Nix", file=file@entry=0x7f0e419940f0 "../backends/nix/pk-backend-nix.cc", line=line@entry=244, 
    func=func@entry=0x7f0e419940b0 "void nix_search_thread(PkBackendJob*, GVariant*, gpointer)", expr=expr@entry=0x0) at ../glib/gtestutils.c:3249
#4  0x00007f0e419718df in nix_search_thread (job=<optimized out>, params=0x16930a0, p=<optimized out>) at ../backends/nix/pk-backend-nix.cc:244
#5  0x00007f0e41971a0f in nix_refresh_thread (job=0x168a480, params=<optimized out>, p=<optimized out>) at ../backends/nix/pk-backend-nix.cc:438
#6  0x000000000042350a in pk_backend_job_thread_setup (thread_data=0x15748c0) at ../src/pk-backend-job.c:724
#7  0x00007f0e44027e0d in g_thread_proxy (data=0x157e460) at ../glib/gthread.c:827
#8  0x00007f0e43b04d40 in start_thread (arg=0x7f0e1aec2640) at pthread_create.c:481
#9  0x00007f0e43a2203f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

We might want to add separateDebugInfo = true; to make debugging easier.

@matthewbauer
Copy link
Member Author

Tried it in a GNOME VM

--- a/nixos/modules/services/x11/desktop-managers/gnome.nix
+++ b/nixos/modules/services/x11/desktop-managers/gnome.nix
@@ -532,9 +532,6 @@ in
             simple-scan
             totem
             yelp
-          ] ++ lib.optionals config.services.flatpak.enable [
-            # Since PackageKit Nix support is not there yet,
-            # only install gnome-software if flatpak is enabled.
             gnome-software
           ])
           config.environment.gnome.excludePackages;

and got a crash on startup (probably triggered by GNOME Software):

Feb 08 23:54:14 nixos PackageKit[1643]: uid 1000 is trying to obtain org.freedesktop.packagekit.system-sources-refresh auth (only_trusted:0)
Feb 08 23:54:14 nixos PackageKit[1643]: uid 1000 obtained auth for org.freedesktop.packagekit.system-sources-refresh
Feb 08 23:54:14 nixos packagekitd[1643]: **
Feb 08 23:54:14 nixos packagekitd[1643]: PackageKit-Nix:ERROR:../backends/nix/pk-backend-nix.cc:244:void nix_search_thread(PkBackendJob*, GVariant*, gpointer): code should not be reached
Feb 08 23:54:14 nixos packagekitd[1643]: Bail out! PackageKit-Nix:ERROR:../backends/nix/pk-backend-nix.cc:244:void nix_search_thread(PkBackendJob*, GVariant*, gpointer): code should not be reached
Feb 08 23:54:14 nixos systemd[1]: Started Process Core Dump (PID 1702/UID 0).
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007f0e4394c533 in __GI_abort () at abort.c:79
#2  0x00007f0e43fc7ddc in g_assertion_message (domain=<optimized out>, file=0x7f0e419940f0 "../backends/nix/pk-backend-nix.cc", line=<optimized out>, func=<optimized out>, message=<optimized out>)
   at ../glib/gtestutils.c:3223
#3  0x00007f0e44026f3b in g_assertion_message_expr (domain=domain@entry=0x7f0e41994125 "PackageKit-Nix", file=file@entry=0x7f0e419940f0 "../backends/nix/pk-backend-nix.cc", line=line@entry=244, 
   func=func@entry=0x7f0e419940b0 "void nix_search_thread(PkBackendJob*, GVariant*, gpointer)", expr=expr@entry=0x0) at ../glib/gtestutils.c:3249
#4  0x00007f0e419718df in nix_search_thread (job=<optimized out>, params=0x16930a0, p=<optimized out>) at ../backends/nix/pk-backend-nix.cc:244
#5  0x00007f0e41971a0f in nix_refresh_thread (job=0x168a480, params=<optimized out>, p=<optimized out>) at ../backends/nix/pk-backend-nix.cc:438
#6  0x000000000042350a in pk_backend_job_thread_setup (thread_data=0x15748c0) at ../src/pk-backend-job.c:724
#7  0x00007f0e44027e0d in g_thread_proxy (data=0x157e460) at ../glib/gthread.c:827
#8  0x00007f0e43b04d40 in start_thread (arg=0x7f0e1aec2640) at pthread_create.c:481
#9  0x00007f0e43a2203f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

We might want to add separateDebugInfo = true; to make debugging easier.

That was a bug in my packagekit code - there's an assert that we don't want : https://github.com/PackageKit/PackageKit/blob/main/backends/nix/pk-backend-nix.cc#L244

Should be fixed !

@jtojnar
Copy link
Contributor

jtojnar commented Feb 9, 2022

Can confirm org.freedesktop.packagekit.system-sources-refresh triggered by the refresh in GNOME Software works. GNOME Software is still empty – I guess that depends on #15932.

Can confirm the following works:

pkcon get-packages
pkcon install celluloid

Had to increase the VM memory limit (get-packages froze on 2G).

Can you please rebase/squash?

@matthewbauer matthewbauer force-pushed the flakes-packagekit branch 2 times, most recently from 6bb1e3b to 714abd9 Compare February 9, 2022 01:22
Fixes NixOS#21230

Use Nix backend for packagekit. Updates to version with my Nix backend
for PackageKit.
Copy link
Contributor

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@matthewbauer matthewbauer merged commit 7ca33e5 into NixOS:master Feb 9, 2022
@thufschmitt
Copy link
Member

This is causing some troubles because it’s relying on the unstable Nix C++ api and is broken with the latest unstable Nix − meaning that it’s not possible to build a system with gnome and the latest Nix anymore.

Is there any strong reason for making the Nix support mandatory and on-by-default?

@jtojnar
Copy link
Contributor

jtojnar commented Feb 28, 2022

@thufschmitt PackageKit is pretty much useless for us without Nix support. And Nix does not really allow us to enable optional features deep in dependency closure easily.

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

9 participants