nix-community / dconf2nix

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

Support dumping custom paths instead of just `/` #22

Closed austinbutler closed 3 years ago

austinbutler commented 3 years ago

Dumped Tilix config

❯ dconf dump /com/gexperts/Tilix/
[profiles/2b7c4080-0ddd-46c5-8f23-563fd3ba789d]
font='MesloLGS Nerd Font 11'
use-system-font=false
visible-name='Default'

Converted Tilix config

❯ dconf2nix -i tilix.conf -o tilix.nix
# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:

let
  mkTuple = lib.hm.gvariant.mkTuple;
in
{
  dconf.settings = {
    "profiles/2b7c4080-0ddd-46c5-8f23-563fd3ba789d" = {
      "font" = "MesloLGS Nerd Font 10";
      "use-system-font" = false;
      "visible-name" = "Default";
    };

  };
}

Resulting incorrect dconf config

❯ dconf dump /profiles/
[2b7c4080-0ddd-46c5-8f23-563fd3ba789d]
font='MesloLGS Nerd Font 11'
use-system-font=false
visible-name='Default'

The config that actually works

{
  home-manager.users.austin = { pkgs, ... }: {
    dconf.settings = {
      "com/gexperts/Tilix/profiles/2b7c4080-0ddd-46c5-8f23-563fd3ba789d" = {
        font = "MesloLGS Nerd Font 11";
        use-system-font = false;
        visible-name = "Default";
      };
    };
  };
}
austinbutler commented 3 years ago

Actually I see what's happening, and it's a me problem :face_with_head_bandage:. dconf2nix can't know where to place the dump when it's not at the root level. Not sure what I was expecting...

I suppose the only suggestion I could offer is a warning or something in the README about dumping keys other than root.

gvolpe commented 3 years ago

I think we could add support for dumping keys other than /, maybe something like:

$ dconf dump /com/gexperts/Tilix/ | dconf2nix --root /com/gexperts/Tilix/ > dconf.nix

Though, I'm not sure how common this use case may be.

gvolpe commented 3 years ago

@austinbutler have a look at #23 and let me know if that looks good to you or you have other suggestions :)

austinbutler commented 3 years ago

@gvolpe that looks great, thanks! At the very least it at least makes it more clear that it's expecting the root by default, which should help dummies like myself in the future :wink:.