nix-community / dconf2nix

:feet: Convert dconf files (e.g. GNOME Shell) to Nix, as expected by Home Manager [maintainer=@jtojnar]
Apache License 2.0
229 stars 6 forks source link

Support NixOS module #85

Open jtojnar opened 1 year ago

jtojnar commented 1 year ago

The Problem

NixOS now supports dconf database generation: https://github.com/NixOS/nixpkgs/pull/234615

The Solution

Add --nixos flag that will make the following changes:

Alternatives

No response

Additional context

No response

Happens in the latest version

l0b0 commented 5 months ago

Does this also need to use mkDouble as discussed?

jtojnar commented 5 months ago

Yes. The loss of precision is a Nix limitation.

l0b0 commented 5 months ago

I wonder if there's anything else missing from the translation instructions. I'm trying to use a section from dconf dump / | dconf2nix verbatim in NixOS configuration:

{
  lib,
  ...
}: {
  programs.dconf.profiles.user.databases = [
    {
      settings = let
        inherit (lib.gvariant) mkTuple mkUint32 mkVariant;
      in {
        "org/gnome/clocks" = {
          world-clocks = [
            {
              location = mkVariant [(mkUint32 2) (mkVariant ["Oslo" "ENGM" false [(mkTuple [1.0506882097005865 0.19344065294494067])] [(mkTuple [1.0506882097005865 0.19344065294494067])]])];
            }
            {
              location = mkVariant [(mkUint32 2) (mkVariant ["London" "EGWU" false [(mkTuple [0.8997172294030767 (-7.272211034407213e-3)])] [(mkTuple [0.8997172294030767 (-7.272211034407213e-3)])]])];
            }
            {
              location = mkVariant [(mkUint32 2) (mkVariant ["Sydney" "YSSY" true [(mkTuple [(-0.592539281052075) 2.638646934988996])] [(mkTuple [(-0.5913757223996479) 2.639228723041856])]])];
            }
          ];
        };
      };
    }
  ];
}

it fails with

error: cannot coerce a set to a string

Full log

I'm not sure what the issue is. It looks like it might be "Elements in a list should have same type.", but that the error handling is broken? And if it is that, how do I convert a list of strings, booleans, and lists to the same type?

Do I need to mkVariant all of them first? No, that doesn't change the error.

jtojnar commented 5 months ago

That was probably fixed by https://github.com/nix-community/dconf2nix/commit/753db879fa49fd0ed5af928662f379a816c7c251

l0b0 commented 5 months ago

That was probably fixed by 753db87

Cool! Would you be OK to cut a release?

l0b0 commented 5 months ago

That was probably fixed by 753db87

It fails with a different error on dconf2nix master:

error: cannot coerce a function to a string

The relevant section of dconf dump / | ./result/bin/dconf2nix:

    "org/gnome/clocks" = {
      world-clocks = [ [
        (mkDictionaryEntry ["location" (mkVariant (mkTuple [ (mkUint32 2) (mkVariant (mkTuple [ "Oslo" "ENGM" false [ (mkTuple [ 1.0506882097005865 0.19344065294494067 ]) ] [ (mkTuple [ 1.0506882097005865 0.19344065294494067 ]) ] ])) ]))])
      ] [
        (mkDictionaryEntry ["location" (mkVariant (mkTuple [ (mkUint32 2) (mkVariant (mkTuple [ "London" "EGWU" false [ (mkTuple [ 0.8997172294030767 (-7.272211034407213e-3) ]) ] [ (mkTuple [ 0.8997172294030767 (-7.272211034407213e-3) ]) ] ])) ]))])
      ] [
        (mkDictionaryEntry ["location" (mkVariant (mkTuple [ (mkUint32 2) (mkVariant (mkTuple [ "Sydney" "YSSY" true [ (mkTuple [ (-0.592539281052075) 2.638646934988996 ]) ] [ (mkTuple [ (-0.5913757223996479) 2.639228723041856 ]) ] ])) ]))])
      ] ];
    };

(Relevant merge request)

jtojnar commented 5 months ago

That is caused by the following difference between Nixpkgs and h-m GVariant implementation:

You need to use

-(mkDictionaryEntry ["location" (mkVariant …)])
+(mkDictionaryEntry "location" (mkVariant …))

Cool! Would you be OK to cut a release?

I want to make my config parse first. Currently, there are still three issues:

[com/github/wwmm/easyeffects/streamoutputs/compressor#0]
sidechain-input-device='alsa_input.platform-snd_aloop.0.analog-stereo'

[org/gnome/gnome-commander/preferences/general]
file-list-tabs=[('file:///home/jtojnar', byte 0x00, byte 0x01, false, false), ('file:///home/jtojnar', 0x01, 0x01, false, false)]

[org/gnome/easytag]
default-path=b'/home/jtojnar/Music'
jtojnar commented 5 months ago

It fails with a different error on dconf2nix master:

error: cannot coerce a function to a string

The misleading error will be fixed by https://github.com/NixOS/nixpkgs/pull/308111.

nixos-discourse commented 2 months ago

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

https://discourse.nixos.org/t/changing-gdm-gsettings-declaratively/49579/6