NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.38k stars 14.33k forks source link

`virt-manager` cannot save preference since nixpkgs-23.11-darwin on macOS #294640

Open Cosmius opened 8 months ago

Cosmius commented 8 months ago

Describe the bug

virt-manager cannot save preference since nixpkgs-23.11-darwin on macOS

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Ensure the nixpkgs is subscribed to https://nixos.org/channels/nixpkgs-23.11-darwin
  2. Execute nix-shell -p virt-manager
  3. Execute virt-manager --no-fork

It says

(virt-manager:19438): dconf-WARNING **: 02:00:34.279: failed to commit changes to dconf: Cannot spawn a message bus without a machine-id: Unable to load /nix/store/mqf3cdsq2hg8ww4ndymblc59r27dyini-glib-2.78.4/var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/nix/store/mqf3cdsq2hg8ww4ndymblc59r27dyini-glib-2.78.4/var/lib/dbus/machine-id”: No such file or directory

and all the preferences, like URI, are never saved.

When I create a dummy /etc/machine-id it says,

(virt-manager:9238): dconf-WARNING **: 01:34:33.120: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY

The package worked perfectly with https://nixos.org/channels/nixpkgs-23.05-darwin. And FYI, the package failed to build with nixpkgs-unstable

Expected behaviour

virt-manager should save the preference.

Additional context

I tried to compare this file https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/virtualization/virt-manager/default.nix from different nixpkgs versions, but found nothing interesting.

As a workaround, I use the following expression instead of virt-manager in my home manager configuration.

(import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixpkgs-23.05-darwin") {}).virt-manager

It seems that it could be a bug of glib or dconf etc, but I am afraid that I know too little of them.

Notify maintainers

@qknight @offline @fpletz @globin

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

cosmia@Cosmias-Air> nix-shell -p nix-info --run "nix-info -m"                                                                                                                                                      ~/projects/system/system-tools
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.4.0, macOS 14.4`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `""`
 - channels(cosmia): `"darwin, home-manager-23.11.tar.gz, nixpkgs-23.11-darwin"`
 - nixpkgs: `/Users/cosmia/.nix-defexpr/channels/nixpkgs`

Add a :+1: reaction to issues you find important.

willbush commented 8 months ago

Strange you didn't have a /etc/machine-id.

systemd uses per-machine identifier — {manpage}machine-id(5) — which must be unique and persistent; otherwise, the system journal may fail to list earlier boots, etc.

systemd generates a random machine-id(5) during boot if it does not already exist, and persists it in /etc/machine-id. As such, it suffices to make that file persistent.

Are you using a impermance setup by chance?

Cosmius commented 8 months ago

Strange you didn't have a /etc/machine-id.

@willbush sorry for missing OS in title. I use nix on macOS. macOS does not have such items.

willbush commented 8 months ago

No my fault! I should have paid closer attention to the description.

similar issue from searching:

I'm guessing macos doesn't use dbus?

Do you have cat /var/lib/dbus/machine-id?

Sorry I'm not super experinced! Just randomly thought I'd try to help.

edit:

another random thought:

what happens if you try to launch GSETTINGS_BACKEND=keyfile virt-manager virt-manager without it using dconf?

Cosmius commented 8 months ago

Thanks a lot! It worked with GSETTINGS_BACKEND=keyfile! I don't know much about gnome stuffs.

And you are right, macOS does not have dbus running. But it seems the previous build did not use this approach, since the preferences of old build are not loaded.🤔 Since it worked magically(?) before, I think there might be a solution other than import the whole thing of older version.

david9991 commented 8 months ago

Same issue here. And GSETTINGS_BACKEND=keyfile saved my day.

Artturin commented 4 days ago

The program could be wrapped with GSETTINGS_BACKEND=keyfile on darwin