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

Support NixOS module #85

Open
1 task done
jtojnar opened this issue Aug 29, 2023 · 8 comments · May be fixed by #108
Open
1 task done

Support NixOS module #85

jtojnar opened this issue Aug 29, 2023 · 8 comments · May be fixed by #108
Labels
enhancement New feature or request

Comments

@jtojnar
Copy link
Contributor

jtojnar commented Aug 29, 2023

The Problem

NixOS now supports dconf database generation: NixOS/nixpkgs#234615

The Solution

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

  • lib.gvariant generates instead of lib.hm.gvariant
  • mkDictionaryEntry takes two arguments instead of a list.
  • int32 needs to be explicitly constructed with mkInt32 (no implicit number literal)

Alternatives

No response

Additional context

No response

Happens in the latest version

  • Yes, this feature is still missing.
@jtojnar jtojnar added the enhancement New feature or request label Aug 29, 2023
@l0b0
Copy link

l0b0 commented Apr 24, 2024

Does this also need to use mkDouble as discussed?

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 24, 2024

Yes. The loss of precision is a Nix limitation.

@l0b0
Copy link

l0b0 commented Apr 24, 2024

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
Copy link
Contributor Author

jtojnar commented Apr 24, 2024

That was probably fixed by 753db87

@jtojnar jtojnar mentioned this issue Apr 24, 2024
1 task
@l0b0
Copy link

l0b0 commented Apr 25, 2024

That was probably fixed by 753db87

Cool! Would you be OK to cut a release?

@l0b0
Copy link

l0b0 commented Apr 25, 2024

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
Copy link
Contributor Author

jtojnar commented Apr 25, 2024

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

  • mkDictionaryEntry takes two arguments instead of a list.

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
Copy link
Contributor Author

jtojnar commented Apr 30, 2024

It fails with a different error on dconf2nix master:

error: cannot coerce a function to a string

The misleading error will be fixed by NixOS/nixpkgs#308111.

@jtojnar jtojnar linked a pull request May 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants